home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / filutil / flex247x.zip / FLEX247 / FLEXDOC.MAN < prev    next >
Text File  |  1994-09-29  |  115KB  |  2,839 lines

  1.  
  2.  
  3.  
  4. FLEXDOC(1)                User Commands                FLEXDOC(1)
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      flexdoc - documentation for flex, fast lexical analyzer gen-
  10.      erator
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      fffflllleeeexxxx [[[[----bbbbccccddddffffhhhhiiiillllnnnnppppssssttttvvvvwwwwBBBBFFFFIIIILLLLTTTTVVVV77778888++++ ----CCCC[[[[aaaaeeeeffffFFFFmmmmrrrr]]]] ----PPPPpppprrrreeeeffffiiiixxxx  ---- SSSSsssskkkkeeeelllleeee----
  14.      ttttoooonnnn]]]] [_f_i_l_e_n_a_m_e ...]
  15.  
  16. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  17.      _f_l_e_x is a  tool  for  generating  _s_c_a_n_n_e_r_s:  programs  which
  18.      recognized  lexical  patterns in text.  _f_l_e_x reads the given
  19.      input files, or its standard input  if  no  file  names  are
  20.      given,  for  a  description  of  a scanner to generate.  The
  21.      description is in the form of pairs of  regular  expressions
  22.      and  C  code,  called  _r_u_l_e_s.  _f_l_e_x  generates as output a C
  23.      source file, lllleeeexxxx....yyyyyyyy....cccc,,,, which defines a routine yyyyyyyylllleeeexxxx(((()))).... This
  24.      file is compiled and linked with the ----llllffffllll library to produce
  25.      an executable.  When the executable is run, it analyzes  its
  26.      input  for occurrences of the regular expressions.  Whenever
  27.      it finds one, it executes the corresponding C code.
  28.  
  29. SSSSOOOOMMMMEEEE SSSSIIIIMMMMPPPPLLLLEEEE EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  30.      First some simple examples to get the flavor of how one uses
  31.      _f_l_e_x.  The  following  _f_l_e_x  input specifies a scanner which
  32.      whenever it encounters the string "username" will replace it
  33.      with the user's login name:
  34.  
  35.          %%
  36.          username    printf( "%s", getlogin() );
  37.  
  38.      By default, any text not matched by a _f_l_e_x scanner is copied
  39.      to  the output, so the net effect of this scanner is to copy
  40.      its input file to its output with each occurrence of  "user-
  41.      name"  expanded.   In  this  input,  there is just one rule.
  42.      "username" is the _p_a_t_t_e_r_n and the "printf"  is  the  _a_c_t_i_o_n.
  43.      The "%%" marks the beginning of the rules.
  44.  
  45.      Here's another simple example:
  46.  
  47.                  int num_lines = 0, num_chars = 0;
  48.  
  49.          %%
  50.          \n      ++num_lines; ++num_chars;
  51.          .       ++num_chars;
  52.  
  53.          %%
  54.          main()
  55.                  {
  56.                  yylex();
  57.                  printf( "# of lines = %d, # of chars = %d\n",
  58.                          num_lines, num_chars );
  59.                  }
  60.  
  61.  
  62.  
  63. Version 2.4        Last change: November 1993                   1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FLEXDOC(1)                User Commands                FLEXDOC(1)
  71.  
  72.  
  73.  
  74.      This scanner counts the number of characters and the  number
  75.      of  lines in its input (it produces no output other than the
  76.      final report on the counts).  The first  line  declares  two
  77.      globals,  "num_lines"  and "num_chars", which are accessible
  78.      both inside yyyyyyyylllleeeexxxx(((()))) and in the mmmmaaaaiiiinnnn(((()))) routine declared after
  79.      the  second  "%%".  There are two rules, one which matches a
  80.      newline ("\n") and increments both the line  count  and  the
  81.      character  count,  and one which matches any character other
  82.      than a newline (indicated by the "." regular expression).
  83.  
  84.      A somewhat more complicated example:
  85.  
  86.          /* scanner for a toy Pascal-like language */
  87.  
  88.          %{
  89.          /* need this for the call to atof() below */
  90.          #include <math.h>
  91.          %}
  92.  
  93.          DIGIT    [0-9]
  94.          ID       [a-z][a-z0-9]*
  95.  
  96.          %%
  97.  
  98.          {DIGIT}+    {
  99.                      printf( "An integer: %s (%d)\n", yytext,
  100.                              atoi( yytext ) );
  101.                      }
  102.  
  103.          {DIGIT}+"."{DIGIT}*        {
  104.                      printf( "A float: %s (%g)\n", yytext,
  105.                              atof( yytext ) );
  106.                      }
  107.  
  108.          if|then|begin|end|procedure|function        {
  109.                      printf( "A keyword: %s\n", yytext );
  110.                      }
  111.  
  112.          {ID}        printf( "An identifier: %s\n", yytext );
  113.  
  114.          "+"|"-"|"*"|"/"   printf( "An operator: %s\n", yytext );
  115.  
  116.          "{"[^}\n]*"}"     /* eat up one-line comments */
  117.  
  118.          [ \t\n]+          /* eat up whitespace */
  119.  
  120.          .           printf( "Unrecognized character: %s\n", yytext );
  121.  
  122.          %%
  123.  
  124.          main( argc, argv )
  125.          int argc;
  126.  
  127.  
  128.  
  129. Version 2.4        Last change: November 1993                   2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. FLEXDOC(1)                User Commands                FLEXDOC(1)
  137.  
  138.  
  139.  
  140.          char **argv;
  141.              {
  142.              ++argv, --argc;  /* skip over program name */
  143.              if ( argc > 0 )
  144.                      yyin = fopen( argv[0], "r" );
  145.              else
  146.                      yyin = stdin;
  147.  
  148.              yylex();
  149.              }
  150.  
  151.      This is the beginnings of a simple scanner  for  a  language
  152.      like  Pascal.   It  identifies different types of _t_o_k_e_n_s and
  153.      reports on what it has seen.
  154.  
  155.      The details of this example will be explained in the follow-
  156.      ing sections.
  157.  
  158. FFFFOOOORRRRMMMMAAAATTTT OOOOFFFF TTTTHHHHEEEE IIIINNNNPPPPUUUUTTTT FFFFIIIILLLLEEEE
  159.      The _f_l_e_x input file consists of three sections, separated by
  160.      a line with just %%%%%%%% in it:
  161.  
  162.          definitions
  163.          %%
  164.          rules
  165.          %%
  166.          user code
  167.  
  168.      The _d_e_f_i_n_i_t_i_o_n_s section contains declarations of simple _n_a_m_e
  169.      definitions  to  simplify  the  scanner  specification,  and
  170.      declarations of _s_t_a_r_t _c_o_n_d_i_t_i_o_n_s, which are explained  in  a
  171.      later section.
  172.  
  173.      Name definitions have the form:
  174.  
  175.          name definition
  176.  
  177.      The "name" is a word beginning with a letter  or  an  under-
  178.      score  ('_')  followed by zero or more letters, digits, '_',
  179.      or '-' (dash).  The definition is  taken  to  begin  at  the
  180.      first  non-white-space character following the name and con-
  181.      tinuing to the end of the line.  The definition  can  subse-
  182.      quently  be referred to using "{name}", which will expand to
  183.      "(definition)".  For example,
  184.  
  185.          DIGIT    [0-9]
  186.          ID       [a-z][a-z0-9]*
  187.  
  188.      defines "DIGIT" to be a regular expression which  matches  a
  189.      single  digit,  and  "ID"  to  be a regular expression which
  190.      matches a letter followed by zero-or-more letters-or-digits.
  191.      A subsequent reference to
  192.  
  193.  
  194.  
  195. Version 2.4        Last change: November 1993                   3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. FLEXDOC(1)                User Commands                FLEXDOC(1)
  203.  
  204.  
  205.  
  206.          {DIGIT}+"."{DIGIT}*
  207.  
  208.      is identical to
  209.  
  210.          ([0-9])+"."([0-9])*
  211.  
  212.      and matches one-or-more digits followed by a '.' followed by
  213.      zero-or-more digits.
  214.  
  215.      The _r_u_l_e_s section of the _f_l_e_x input  contains  a  series  of
  216.      rules of the form:
  217.  
  218.          pattern   action
  219.  
  220.      where the pattern must be unindented  and  the  action  must
  221.      begin on the same line.
  222.  
  223.      See below for a further description of patterns and actions.
  224.  
  225.      Finally, the user code section is simply copied to  lllleeeexxxx....yyyyyyyy....cccc
  226.      verbatim.   It  is used for companion routines which call or
  227.      are called by the scanner.  The presence of this section  is
  228.      optional;  if it is missing, the second %%%%%%%% in the input file
  229.      may be skipped, too.
  230.  
  231.      In the definitions and rules sections, any _i_n_d_e_n_t_e_d text  or
  232.      text  enclosed in %%%%{{{{ and %%%%}}}} is copied verbatim to the output
  233.      (with the %{}'s removed).  The %{}'s must appear  unindented
  234.      on lines by themselves.
  235.  
  236.      In the rules section, any indented  or  %{}  text  appearing
  237.      before the first rule may be used to declare variables which
  238.      are local to the scanning routine and  (after  the  declara-
  239.      tions)  code  which  is to be executed whenever the scanning
  240.      routine is entered.  Other indented or %{} text in the  rule
  241.      section  is  still  copied to the output, but its meaning is
  242.      not well-defined and it may well cause  compile-time  errors
  243.      (this feature is present for _P_O_S_I_X compliance; see below for
  244.      other such features).
  245.  
  246.      In the definitions section (but not in the  rules  section),
  247.      an  unindented comment (i.e., a line beginning with "/*") is
  248.      also copied verbatim to the output up to the next "*/".
  249.  
  250. PPPPAAAATTTTTTTTEEEERRRRNNNNSSSS
  251.      The patterns in the input are written using an extended  set
  252.      of regular expressions.  These are:
  253.  
  254.          x          match the character 'x'
  255.          .          any character except newline
  256.          [xyz]      a "character class"; in this case, the pattern
  257.                       matches either an 'x', a 'y', or a 'z'
  258.  
  259.  
  260.  
  261. Version 2.4        Last change: November 1993                   4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. FLEXDOC(1)                User Commands                FLEXDOC(1)
  269.  
  270.  
  271.  
  272.          [abj-oZ]   a "character class" with a range in it; matches
  273.                       an 'a', a 'b', any letter from 'j' through 'o',
  274.                       or a 'Z'
  275.          [^A-Z]     a "negated character class", i.e., any character
  276.                       but those in the class.  In this case, any
  277.                       character EXCEPT an uppercase letter.
  278.          [^A-Z\n]   any character EXCEPT an uppercase letter or
  279.                       a newline
  280.          r*         zero or more r's, where r is any regular expression
  281.          r+         one or more r's
  282.          r?         zero or one r's (that is, "an optional r")
  283.          r{2,5}     anywhere from two to five r's
  284.          r{2,}      two or more r's
  285.          r{4}       exactly 4 r's
  286.          {name}     the expansion of the "name" definition
  287.                     (see above)
  288.          "[xyz]\"foo"
  289.                     the literal string: [xyz]"foo
  290.          \X         if X is an 'a', 'b', 'f', 'n', 'r', 't', or 'v',
  291.                       then the ANSI-C interpretation of \x.
  292.                       Otherwise, a literal 'X' (used to escape
  293.                       operators such as '*')
  294.          \123       the character with octal value 123
  295.          \x2a       the character with hexadecimal value 2a
  296.          (r)        match an r; parentheses are used to override
  297.                       precedence (see below)
  298.  
  299.  
  300.          rs         the regular expression r followed by the
  301.                       regular expression s; called "concatenation"
  302.  
  303.  
  304.          r|s        either an r or an s
  305.  
  306.  
  307.          r/s        an r but only if it is followed by an s.  The
  308.                       s is not part of the matched text.  This type
  309.                       of pattern is called as "trailing context".
  310.          ^r         an r, but only at the beginning of a line
  311.          r$         an r, but only at the end of a line.  Equivalent
  312.                       to "r/\n".
  313.  
  314.  
  315.          <s>r       an r, but only in start condition s (see
  316.                     below for discussion of start conditions)
  317.          <s1,s2,s3>r
  318.                     same, but in any of start conditions s1,
  319.                     s2, or s3
  320.          <*>r       an r in any start condition, even an exclusive one.
  321.  
  322.  
  323.          <<EOF>>    an end-of-file
  324.  
  325.  
  326.  
  327. Version 2.4        Last change: November 1993                   5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. FLEXDOC(1)                User Commands                FLEXDOC(1)
  335.  
  336.  
  337.  
  338.          <s1,s2><<EOF>>
  339.                     an end-of-file when in start condition s1 or s2
  340.  
  341.      Note that inside of a character class, all  regular  expres-
  342.      sion  operators  lose  their  special  meaning except escape
  343.      ('\') and the character class operators, '-', ']',  and,  at
  344.      the beginning of the class, '^'.
  345.  
  346.      The regular expressions listed above are  grouped  according
  347.      to  precedence, from highest precedence at the top to lowest
  348.      at the bottom.   Those  grouped  together  have  equal  pre-
  349.      cedence.  For example,
  350.  
  351.          foo|bar*
  352.  
  353.      is the same as
  354.  
  355.          (foo)|(ba(r*))
  356.  
  357.      since the '*' operator has higher precedence than concatena-
  358.      tion, and concatenation higher than alternation ('|').  This
  359.      pattern therefore matches _e_i_t_h_e_r the  string  "foo"  _o_r  the
  360.      string "ba" followed by zero-or-more r's.  To match "foo" or
  361.      zero-or-more "bar"'s, use:
  362.  
  363.          foo|(bar)*
  364.  
  365.      and to match zero-or-more "foo"'s-or-"bar"'s:
  366.  
  367.          (foo|bar)*
  368.  
  369.  
  370.      Some notes on patterns:
  371.  
  372.      -    A negated character class such as the example  "[^A-Z]"
  373.           above   _w_i_l_l   _m_a_t_c_h  _a  _n_e_w_l_i_n_e  unless  "\n"  (or  an
  374.           equivalent escape sequence) is one  of  the  characters
  375.           explicitly  present  in  the  negated  character  class
  376.           (e.g., "[^A-Z\n]").  This is unlike how many other reg-
  377.           ular  expression tools treat negated character classes,
  378.           but unfortunately  the  inconsistency  is  historically
  379.           entrenched.   Matching  newlines  means  that a pattern
  380.           like [^"]* can match the entire  input  unless  there's
  381.           another quote in the input.
  382.  
  383.      -    A rule can have at most one instance of  trailing  con-
  384.           text (the '/' operator or the '$' operator).  The start
  385.           condition, '^', and "<<EOF>>" patterns can  only  occur
  386.           at the beginning of a pattern, and, as well as with '/'
  387.           and '$', cannot be grouped inside parentheses.   A  '^'
  388.           which  does  not  occur at the beginning of a rule or a
  389.           '$' which does not occur at the end of a rule loses its
  390.  
  391.  
  392.  
  393. Version 2.4        Last change: November 1993                   6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. FLEXDOC(1)                User Commands                FLEXDOC(1)
  401.  
  402.  
  403.  
  404.           special  properties  and is treated as a normal charac-
  405.           ter.
  406.  
  407.           The following are illegal:
  408.  
  409.               foo/bar$
  410.               <sc1>foo<sc2>bar
  411.  
  412.           Note  that  the  first  of  these,   can   be   written
  413.           "foo/bar\n".
  414.  
  415.           The following will result in '$' or '^'  being  treated
  416.           as a normal character:
  417.  
  418.               foo|(bar$)
  419.               foo|^bar
  420.  
  421.           If what's wanted is a  "foo"  or  a  bar-followed-by-a-
  422.           newline,  the  following could be used (the special '|'
  423.           action is explained below):
  424.  
  425.               foo      |
  426.               bar$     /* action goes here */
  427.  
  428.           A similar trick will work for matching a foo or a  bar-
  429.           at-the-beginning-of-a-line.
  430.  
  431. HHHHOOOOWWWW TTTTHHHHEEEE IIIINNNNPPPPUUUUTTTT IIIISSSS MMMMAAAATTTTCCCCHHHHEEEEDDDD
  432.      When the generated scanner is run,  it  analyzes  its  input
  433.      looking  for strings which match any of its patterns.  If it
  434.      finds more than one match, it takes  the  one  matching  the
  435.      most  text  (for  trailing  context rules, this includes the
  436.      length of the trailing part, even though  it  will  then  be
  437.      returned  to the input).  If it finds two or more matches of
  438.      the same length, the rule listed first  in  the  _f_l_e_x  input
  439.      file is chosen.
  440.  
  441.      Once the match is determined, the text corresponding to  the
  442.      match  (called  the  _t_o_k_e_n)  is made available in the global
  443.      character pointer yyyyyyyytttteeeexxxxtttt,,,,  and  its  length  in  the  global
  444.      integer yyyyyyyylllleeeennnngggg.... The _a_c_t_i_o_n corresponding to the matched pat-
  445.      tern is  then  executed  (a  more  detailed  description  of
  446.      actions  follows),  and  then the remaining input is scanned
  447.      for another match.
  448.  
  449.      If no match is found, then the _d_e_f_a_u_l_t _r_u_l_e is executed: the
  450.      next character in the input is considered matched and copied
  451.      to the standard output.  Thus, the simplest legal _f_l_e_x input
  452.      is:
  453.  
  454.          %%
  455.  
  456.  
  457.  
  458.  
  459. Version 2.4        Last change: November 1993                   7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. FLEXDOC(1)                User Commands                FLEXDOC(1)
  467.  
  468.  
  469.  
  470.      which generates a scanner that simply copies its input  (one
  471.      character at a time) to its output.
  472.  
  473.      Note that yyyyyyyytttteeeexxxxtttt can  be  defined  in  two  different  ways:
  474.      either  as  a character _p_o_i_n_t_e_r or as a character _a_r_r_a_y. You
  475.      can control which definition _f_l_e_x uses by including  one  of
  476.      the  special  directives  %%%%ppppooooiiiinnnntttteeeerrrr  or  %%%%aaaarrrrrrrraaaayyyy  in the first
  477.      (definitions) section of your flex input.   The  default  is
  478.      %%%%ppppooooiiiinnnntttteeeerrrr,,,, unless you use the ----llll lex compatibility option, in
  479.      which case yyyyyyyytttteeeexxxxtttt will be an array.  The advantage of  using
  480.      %%%%ppppooooiiiinnnntttteeeerrrr  is  substantially  faster  scanning  and no buffer
  481.      overflow when matching very large tokens (unless you run out
  482.      of  dynamic  memory).  The disadvantage is that you are res-
  483.      tricted in how your actions can modify yyyyyyyytttteeeexxxxtttt (see the  next
  484.      section),  and  calls  to  the iiiinnnnppppuuuutttt(((()))) and uuuunnnnppppuuuutttt(((()))) functions
  485.      destroy the present contents of yyyyyyyytttteeeexxxxtttt,,,, which can be a  con-
  486.      siderable porting headache when moving between different _l_e_x
  487.      versions.
  488.  
  489.      The advantage of %%%%aaaarrrrrrrraaaayyyy is that you can then  modify  yyyyyyyytttteeeexxxxtttt
  490.      to your heart's content, and calls to iiiinnnnppppuuuutttt(((()))) and uuuunnnnppppuuuutttt(((()))) do
  491.      not destroy yyyyyyyytttteeeexxxxtttt (see below).  Furthermore,  existing  _l_e_x
  492.      programs  sometimes  access yyyyyyyytttteeeexxxxtttt externally using declara-
  493.      tions of the form:
  494.          extern char yytext[];
  495.      This definition is erroneous when used  with  %%%%ppppooooiiiinnnntttteeeerrrr,,,,  but
  496.      correct for %%%%aaaarrrrrrrraaaayyyy....
  497.  
  498.      %%%%aaaarrrrrrrraaaayyyy defines yyyyyyyytttteeeexxxxtttt to be an array of  YYYYYYYYLLLLMMMMAAAAXXXX  characters,
  499.      which  defaults to a fairly large value.  You can change the
  500.      size by simply #define'ing YYYYYYYYLLLLMMMMAAAAXXXX to a  different  value  in
  501.      the  first  section of your _f_l_e_x input.  As mentioned above,
  502.      with %%%%ppppooooiiiinnnntttteeeerrrr yytext grows dynamically to  accomodate  large
  503.      tokens.   While this means your %%%%ppppooooiiiinnnntttteeeerrrr scanner can accomo-
  504.      date very large tokens (such as matching  entire  blocks  of
  505.      comments),  bear  in  mind  that  each time the scanner must
  506.      resize yyyyyyyytttteeeexxxxtttt it also must rescan the entire token from  the
  507.      beginning,  so  matching such tokens can prove slow.  yyyyyyyytttteeeexxxxtttt
  508.      presently does _n_o_t dynamically grow if  a  call  to  uuuunnnnppppuuuutttt(((())))
  509.      results  in too much text being pushed back; instead, a run-
  510.      time error results.
  511.  
  512.      Also note that  you  cannot  use  %%%%aaaarrrrrrrraaaayyyy  with  C++  scanner
  513.      classes (the ----++++ option; see below).
  514.  
  515. AAAACCCCTTTTIIIIOOOONNNNSSSS
  516.      Each pattern in a rule has a corresponding action, which can
  517.      be any arbitrary C statement.  The pattern ends at the first
  518.      non-escaped whitespace character; the remainder of the  line
  519.      is  its  action.  If the action is empty, then when the pat-
  520.      tern is matched the input token is  simply  discarded.   For
  521.      example,  here  is  the  specification  for  a program which
  522.  
  523.  
  524.  
  525. Version 2.4        Last change: November 1993                   8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. FLEXDOC(1)                User Commands                FLEXDOC(1)
  533.  
  534.  
  535.  
  536.      deletes all occurrences of "zap me" from its input:
  537.  
  538.          %%
  539.          "zap me"
  540.  
  541.      (It will copy all other characters in the input to the  out-
  542.      put since they will be matched by the default rule.)
  543.  
  544.      Here is a program which compresses multiple blanks and  tabs
  545.      down  to a single blank, and throws away whitespace found at
  546.      the end of a line:
  547.  
  548.          %%
  549.          [ \t]+        putchar( ' ' );
  550.          [ \t]+$       /* ignore this token */
  551.  
  552.  
  553.      If the action contains a '{', then the action spans till the
  554.      balancing  '}'  is  found, and the action may cross multiple
  555.      lines.  _f_l_e_x knows about C strings and comments and won't be
  556.      fooled  by braces found within them, but also allows actions
  557.      to begin with %%%%{{{{ and will consider the action to be all  the
  558.      text up to the next %%%%}}}} (regardless of ordinary braces inside
  559.      the action).
  560.  
  561.      An action consisting solely of a vertical  bar  ('|')  means
  562.      "same  as  the  action for the next rule."  See below for an
  563.      illustration.
  564.  
  565.      Actions can  include  arbitrary  C  code,  including  rrrreeeettttuuuurrrrnnnn
  566.      statements  to  return  a  value  to whatever routine called
  567.      yyyyyyyylllleeeexxxx(((()))).... Each time yyyyyyyylllleeeexxxx(((()))) is called it continues processing
  568.      tokens  from  where it last left off until it either reaches
  569.      the end of the file or executes a return.
  570.  
  571.      Actions are free to modify yyyyyyyytttteeeexxxxtttt except for lengthening  it
  572.      (adding  characters  to  its end--these will overwrite later
  573.      characters in the input stream).  Modifying the final  char-
  574.      acter  of  yytext  may  alter  whether when scanning resumes
  575.      rules anchored with '^' are active.  Specifically,  changing
  576.      the  final  character  of  yytext to a newline will activate
  577.      such rules on the next scan, and  changing  it  to  anything
  578.      else  will  deactivate  the rules.  Users should not rely on
  579.      this behavior being present in  future  releases.   Finally,
  580.      note  that  none of this paragraph applies when using %%%%aaaarrrrrrrraaaayyyy
  581.      (see above).
  582.  
  583.      Actions are free to modify yyyyyyyylllleeeennnngggg except they should not  do
  584.      so if the action also includes use of yyyyyyyymmmmoooorrrreeee(((()))) (see below).
  585.  
  586.      There are a  number  of  special  directives  which  can  be
  587.      included within an action:
  588.  
  589.  
  590.  
  591. Version 2.4        Last change: November 1993                   9
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. FLEXDOC(1)                User Commands                FLEXDOC(1)
  599.  
  600.  
  601.  
  602.      -    EEEECCCCHHHHOOOO copies yytext to the scanner's output.
  603.  
  604.      -    BBBBEEEEGGGGIIIINNNN followed by the name of a start condition  places
  605.           the  scanner  in the corresponding start condition (see
  606.           below).
  607.  
  608.      -    RRRREEEEJJJJEEEECCCCTTTT directs the scanner to proceed on to the "second
  609.           best"  rule which matched the input (or a prefix of the
  610.           input).  The rule is chosen as described above in  "How
  611.           the  Input  is  Matched",  and yyyyyyyytttteeeexxxxtttt and yyyyyyyylllleeeennnngggg set up
  612.           appropriately.  It may either be one which  matched  as
  613.           much  text as the originally chosen rule but came later
  614.           in the _f_l_e_x input file, or one which matched less text.
  615.           For example, the following will both count the words in
  616.           the input  and  call  the  routine  special()  whenever
  617.           "frob" is seen:
  618.  
  619.                       int word_count = 0;
  620.               %%
  621.  
  622.               frob        special(); REJECT;
  623.               [^ \t\n]+   ++word_count;
  624.  
  625.           Without the RRRREEEEJJJJEEEECCCCTTTT,,,, any "frob"'s in the input would not
  626.           be  counted  as  words, since the scanner normally exe-
  627.           cutes only one action per token.  Multiple RRRREEEEJJJJEEEECCCCTTTT''''ssss are
  628.           allowed,  each  one finding the next best choice to the
  629.           currently active rule.  For example, when the following
  630.           scanner  scans the token "abcd", it will write "abcdab-
  631.           caba" to the output:
  632.  
  633.               %%
  634.               a        |
  635.               ab       |
  636.               abc      |
  637.               abcd     ECHO; REJECT;
  638.               .|\n     /* eat up any unmatched character */
  639.  
  640.           (The first three rules share the fourth's action  since
  641.           they use the special '|' action.)  RRRREEEEJJJJEEEECCCCTTTT is a particu-
  642.           larly expensive feature in terms  scanner  performance;
  643.           if  it  is used in _a_n_y of the scanner's actions it will
  644.           slow down _a_l_l of the scanner's matching.   Furthermore,
  645.           RRRREEEEJJJJEEEECCCCTTTT  cannot be used with the -_C_f or -_C_F options (see
  646.           below).
  647.  
  648.           Note also that unlike the other special actions, RRRREEEEJJJJEEEECCCCTTTT
  649.           is  a  _b_r_a_n_c_h;  code  immediately  following  it in the
  650.           action will _n_o_t be executed.
  651.  
  652.      -    yyyyyyyymmmmoooorrrreeee(((()))) tells  the  scanner  that  the  next  time  it
  653.           matches  a  rule,  the  corresponding  token  should be
  654.  
  655.  
  656.  
  657. Version 2.4        Last change: November 1993                  10
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. FLEXDOC(1)                User Commands                FLEXDOC(1)
  665.  
  666.  
  667.  
  668.           _a_p_p_e_n_d_e_d onto the current value of yyyyyyyytttteeeexxxxtttt  rather  than
  669.           replacing  it.   For  example,  given  the input "mega-
  670.           kludge" the following will write "mega-mega-kludge"  to
  671.           the output:
  672.  
  673.               %%
  674.               mega-    ECHO; yymore();
  675.               kludge   ECHO;
  676.  
  677.           First "mega-" is matched  and  echoed  to  the  output.
  678.           Then  "kludge"  is matched, but the previous "mega-" is
  679.           still hanging around at the beginning of yyyyyyyytttteeeexxxxtttt so  the
  680.           EEEECCCCHHHHOOOO  for  the "kludge" rule will actually write "mega-
  681.           kludge".  The presence of  yyyyyyyymmmmoooorrrreeee(((())))  in  the  scanner's
  682.           action  entails  a  minor  performance  penalty  in the
  683.           scanner's matching speed.
  684.  
  685.      -    yyyyyyyylllleeeessssssss((((nnnn)))) returns all but the first _n characters of the
  686.           current token back to the input stream, where they will
  687.           be rescanned when the scanner looks for the next match.
  688.           yyyyyyyytttteeeexxxxtttt  and  yyyyyyyylllleeeennnngggg  are  adjusted appropriately (e.g.,
  689.           yyyyyyyylllleeeennnngggg will now be equal to _n ).  For example,  on  the
  690.           input  "foobar"  the  following will write out "foobar-
  691.           bar":
  692.  
  693.               %%
  694.               foobar    ECHO; yyless(3);
  695.               [a-z]+    ECHO;
  696.  
  697.           An argument of  0  to  yyyyyyyylllleeeessssssss  will  cause  the  entire
  698.           current  input  string  to  be  scanned  again.  Unless
  699.           you've changed how the scanner will  subsequently  pro-
  700.           cess  its  input  (using BBBBEEEEGGGGIIIINNNN,,,, for example), this will
  701.           result in an endless loop.
  702.  
  703.      Note that yyyyyyyylllleeeessssssss is a macro and can only be used in the flex
  704.      input file, not from other source files.
  705.  
  706.      -    uuuunnnnppppuuuutttt((((cccc)))) puts the  character  _c  back  onto  the  input
  707.           stream.   It  will  be the next character scanned.  The
  708.           following action will take the current token and  cause
  709.           it to be rescanned enclosed in parentheses.
  710.  
  711.               {
  712.               int i;
  713.               unput( ')' );
  714.               for ( i = yyleng - 1; i >= 0; --i )
  715.                   unput( yytext[i] );
  716.               unput( '(' );
  717.               }
  718.  
  719.           Note that since each uuuunnnnppppuuuutttt(((()))) puts the  given  character
  720.  
  721.  
  722.  
  723. Version 2.4        Last change: November 1993                  11
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. FLEXDOC(1)                User Commands                FLEXDOC(1)
  731.  
  732.  
  733.  
  734.           back at the _b_e_g_i_n_n_i_n_g of the input stream, pushing back
  735.           strings must be done back-to-front.  Also note that you
  736.           cannot put back EEEEOOOOFFFF to attempt to mark the input stream
  737.           with an end-of-file.
  738.  
  739.      -    iiiinnnnppppuuuutttt(((()))) reads the next character from the input stream.
  740.           For  example, the following is one way to eat up C com-
  741.           ments:
  742.  
  743.               %%
  744.               "/*"        {
  745.                           register int c;
  746.  
  747.                           for ( ; ; )
  748.                               {
  749.                               while ( (c = input()) != '*' &&
  750.                                       c != EOF )
  751.                                   ;    /* eat up text of comment */
  752.  
  753.                               if ( c == '*' )
  754.                                   {
  755.                                   while ( (c = input()) == '*' )
  756.                                       ;
  757.                                   if ( c == '/' )
  758.                                       break;    /* found the end */
  759.                                   }
  760.  
  761.                               if ( c == EOF )
  762.                                   {
  763.                                   error( "EOF in comment" );
  764.                                   break;
  765.                                   }
  766.                               }
  767.                           }
  768.  
  769.           (Note that if the scanner is compiled using  CCCC++++++++,,,,  then
  770.           iiiinnnnppppuuuutttt(((())))  is  instead referred to as yyyyyyyyiiiinnnnppppuuuutttt(((()))),,,, in order
  771.           to avoid a name clash with the CCCC++++++++ stream by  the  name
  772.           of _i_n_p_u_t.)
  773.  
  774.      -    yyyyyyyytttteeeerrrrmmmmiiiinnnnaaaatttteeee(((()))) can be used in lieu of a return statement
  775.           in  an action.  It terminates the scanner and returns a
  776.           0 to the scanner's caller, indicating "all  done".   By
  777.           default,  yyyyyyyytttteeeerrrrmmmmiiiinnnnaaaatttteeee(((())))  is also called when an end-of-
  778.           file is encountered.  It is a macro and  may  be  rede-
  779.           fined.
  780.  
  781. TTTTHHHHEEEE GGGGEEEENNNNEEEERRRRAAAATTTTEEEEDDDD SSSSCCCCAAAANNNNNNNNEEEERRRR
  782.      The output of _f_l_e_x is the file lllleeeexxxx....yyyyyyyy....cccc,,,, which contains  the
  783.      scanning  routine yyyyyyyylllleeeexxxx(((()))),,,, a number of tables used by it for
  784.      matching tokens, and a number of auxiliary routines and mac-
  785.      ros.  By default, yyyyyyyylllleeeexxxx(((()))) is declared as follows:
  786.  
  787.  
  788.  
  789. Version 2.4        Last change: November 1993                  12
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. FLEXDOC(1)                User Commands                FLEXDOC(1)
  797.  
  798.  
  799.  
  800.          int yylex()
  801.              {
  802.              ... various definitions and the actions in here ...
  803.              }
  804.  
  805.      (If your environment supports function prototypes,  then  it
  806.      will  be  "int  yylex(  void  )".)   This  definition may be
  807.      changed by defining the "YY_DECL" macro.  For  example,  you
  808.      could use:
  809.  
  810.          #define YY_DECL float lexscan( a, b ) float a, b;
  811.  
  812.      to give the scanning routine the name _l_e_x_s_c_a_n,  returning  a
  813.      float, and taking two floats as arguments.  Note that if you
  814.      give  arguments  to  the  scanning  routine  using  a   K&R-
  815.      style/non-prototyped  function  declaration,  you  must ter-
  816.      minate the definition with a semi-colon (;).
  817.  
  818.      Whenever yyyyyyyylllleeeexxxx(((()))) is called, it scans tokens from the  global
  819.      input  file  _y_y_i_n  (which  defaults to stdin).  It continues
  820.      until it either reaches an end-of-file (at  which  point  it
  821.      returns the value 0) or one of its actions executes a _r_e_t_u_r_n
  822.      statement.
  823.  
  824.      If the scanner reaches an end-of-file, subsequent calls  are
  825.      undefined  unless either _y_y_i_n is pointed at a new input file
  826.      (in which case scanning continues from that file), or yyyyyyyyrrrreeeessss----
  827.      ttttaaaarrrrtttt(((())))  is called.  yyyyyyyyrrrreeeessssttttaaaarrrrtttt(((()))) takes one argument, a FFFFIIIILLLLEEEE ****
  828.      pointer, and initializes _y_y_i_n for scanning from  that  file.
  829.      Essentially  there  is  no difference between just assigning
  830.      _y_y_i_n to a new input file or using yyyyyyyyrrrreeeessssttttaaaarrrrtttt(((()))) to do so;  the
  831.      latter is available for compatibility with previous versions
  832.      of _f_l_e_x, and because it can be used to switch input files in
  833.      the  middle  of scanning.  It can also be used to throw away
  834.      the current input buffer, by calling it with an argument  of
  835.      _y_y_i_n.
  836.  
  837.      If yyyyyyyylllleeeexxxx(((()))) stops scanning due to executing a  _r_e_t_u_r_n  state-
  838.      ment  in  one of the actions, the scanner may then be called
  839.      again and it will resume scanning where it left off.
  840.  
  841.      By default (and for purposes  of  efficiency),  the  scanner
  842.      uses  block-reads  rather  than  simple _g_e_t_c() calls to read
  843.      characters from _y_y_i_n. The nature of how it  gets  its  input
  844.      can   be   controlled   by   defining  the  YYYYYYYY____IIIINNNNPPPPUUUUTTTT  macro.
  845.      YY_INPUT's           calling           sequence           is
  846.      "YY_INPUT(buf,result,max_size)".   Its action is to place up
  847.      to _m_a_x__s_i_z_e characters in the character array _b_u_f and return
  848.      in  the integer variable _r_e_s_u_l_t either the number of charac-
  849.      ters read or the constant YY_NULL (0  on  Unix  systems)  to
  850.      indicate  EOF.   The  default YY_INPUT reads from the global
  851.      file-pointer "yyin".
  852.  
  853.  
  854.  
  855. Version 2.4        Last change: November 1993                  13
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. FLEXDOC(1)                User Commands                FLEXDOC(1)
  863.  
  864.  
  865.  
  866.      A sample definition of YY_INPUT (in the definitions  section
  867.      of the input file):
  868.  
  869.          %{
  870.          #define YY_INPUT(buf,result,max_size) \
  871.              { \
  872.              int c = getchar(); \
  873.              result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
  874.              }
  875.          %}
  876.  
  877.      This definition will change the input  processing  to  occur
  878.      one character at a time.
  879.  
  880.      You also can add in things like keeping track of  the  input
  881.      line  number  this  way; but don't expect your scanner to go
  882.      very fast.
  883.  
  884.      When the scanner receives  an  end-of-file  indication  from
  885.      YY_INPUT, it then checks the yyyyyyyywwwwrrrraaaapppp(((()))) function.  If yyyyyyyywwwwrrrraaaapppp(((())))
  886.      returns false (zero), then it is assumed that  the  function
  887.      has  gone  ahead  and  set up _y_y_i_n to point to another input
  888.      file, and scanning continues.   If  it  returns  true  (non-
  889.      zero),  then  the  scanner  terminates,  returning  0 to its
  890.      caller.
  891.  
  892.      The default yyyyyyyywwwwrrrraaaapppp(((()))) always returns 1.
  893.  
  894.      The scanner writes its  EEEECCCCHHHHOOOO  output  to  the  _y_y_o_u_t  global
  895.      (default, stdout), which may be redefined by the user simply
  896.      by assigning it to some other FFFFIIIILLLLEEEE pointer.
  897.  
  898. SSSSTTTTAAAARRRRTTTT CCCCOOOONNNNDDDDIIIITTTTIIIIOOOONNNNSSSS
  899.      _f_l_e_x  provides  a  mechanism  for  conditionally  activating
  900.      rules.   Any rule whose pattern is prefixed with "<sc>" will
  901.      only be active when the scanner is in  the  start  condition
  902.      named "sc".  For example,
  903.  
  904.          <STRING>[^"]*        { /* eat up the string body ... */
  905.                      ...
  906.                      }
  907.  
  908.      will be active only when the  scanner  is  in  the  "STRING"
  909.      start condition, and
  910.  
  911.          <INITIAL,STRING,QUOTE>\.        { /* handle an escape ... */
  912.                      ...
  913.                      }
  914.  
  915.      will be active only when  the  current  start  condition  is
  916.      either "INITIAL", "STRING", or "QUOTE".
  917.  
  918.  
  919.  
  920.  
  921. Version 2.4        Last change: November 1993                  14
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. FLEXDOC(1)                User Commands                FLEXDOC(1)
  929.  
  930.  
  931.  
  932.      Start conditions are declared  in  the  definitions  (first)
  933.      section  of  the input using unindented lines beginning with
  934.      either %%%%ssss or %%%%xxxx followed by a list  of  names.   The  former
  935.      declares  _i_n_c_l_u_s_i_v_e  start  conditions, the latter _e_x_c_l_u_s_i_v_e
  936.      start conditions.  A start condition is activated using  the
  937.      BBBBEEEEGGGGIIIINNNN  action.   Until  the  next  BBBBEEEEGGGGIIIINNNN action is executed,
  938.      rules with the given start  condition  will  be  active  and
  939.      rules  with other start conditions will be inactive.  If the
  940.      start condition is _i_n_c_l_u_s_i_v_e, then rules with no start  con-
  941.      ditions  at  all  will  also be active.  If it is _e_x_c_l_u_s_i_v_e,
  942.      then _o_n_l_y rules qualified with the start condition  will  be
  943.      active.   A  set  of  rules contingent on the same exclusive
  944.      start condition describe a scanner which is  independent  of
  945.      any  of the other rules in the _f_l_e_x input.  Because of this,
  946.      exclusive start conditions make it easy  to  specify  "mini-
  947.      scanners"  which scan portions of the input that are syntac-
  948.      tically different from the rest (e.g., comments).
  949.  
  950.      If the distinction between  inclusive  and  exclusive  start
  951.      conditions  is still a little vague, here's a simple example
  952.      illustrating the connection between the  two.   The  set  of
  953.      rules:
  954.  
  955.          %s example
  956.          %%
  957.          <example>foo           /* do something */
  958.  
  959.      is equivalent to
  960.  
  961.          %x example
  962.          %%
  963.          <INITIAL,example>foo   /* do something */
  964.  
  965.  
  966.      Also note that the  special  start-condition  specifier  <<<<****>>>>
  967.      matches  every  start  condition.   Thus,  the above example
  968.      could also have been written;
  969.  
  970.          %x example
  971.          %%
  972.          <*>foo   /* do something */
  973.  
  974.  
  975.      The default rule (to EEEECCCCHHHHOOOO any unmatched  character)  remains
  976.      active in start conditions.
  977.  
  978.      BBBBEEEEGGGGIIIINNNN((((0000)))) returns to the original state where only the  rules
  979.      with no start conditions are active.  This state can also be
  980.      referred   to   as   the   start-condition   "INITIAL",   so
  981.      BBBBEEEEGGGGIIIINNNN((((IIIINNNNIIIITTTTIIIIAAAALLLL))))  is  equivalent to BBBBEEEEGGGGIIIINNNN((((0000)))).... (The parentheses
  982.      around the start condition name are  not  required  but  are
  983.      considered good style.)
  984.  
  985.  
  986.  
  987. Version 2.4        Last change: November 1993                  15
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. FLEXDOC(1)                User Commands                FLEXDOC(1)
  995.  
  996.  
  997.  
  998.      BBBBEEEEGGGGIIIINNNN actions can also be given  as  indented  code  at  the
  999.      beginning  of the rules section.  For example, the following
  1000.      will cause the scanner to enter the "SPECIAL"  start  condi-
  1001.      tion  whenever  _y_y_l_e_x()  is  called  and the global variable
  1002.      _e_n_t_e_r__s_p_e_c_i_a_l is true:
  1003.  
  1004.                  int enter_special;
  1005.  
  1006.          %x SPECIAL
  1007.          %%
  1008.                  if ( enter_special )
  1009.                      BEGIN(SPECIAL);
  1010.  
  1011.          <SPECIAL>blahblahblah
  1012.          ...more rules follow...
  1013.  
  1014.  
  1015.      To illustrate the  uses  of  start  conditions,  here  is  a
  1016.      scanner  which  provides  two different interpretations of a
  1017.      string like "123.456".  By default it will treat  it  as  as
  1018.      three  tokens,  the  integer  "123",  a  dot  ('.'), and the
  1019.      integer "456".  But if the string is preceded earlier in the
  1020.      line  by  the  string  "expect-floats" it will treat it as a
  1021.      single token, the floating-point number 123.456:
  1022.  
  1023.          %{
  1024.          #include <math.h>
  1025.          %}
  1026.          %s expect
  1027.  
  1028.          %%
  1029.          expect-floats        BEGIN(expect);
  1030.  
  1031.          <expect>[0-9]+"."[0-9]+      {
  1032.                      printf( "found a float, = %f\n",
  1033.                              atof( yytext ) );
  1034.                      }
  1035.          <expect>\n           {
  1036.                      /* that's the end of the line, so
  1037.                       * we need another "expect-number"
  1038.                       * before we'll recognize any more
  1039.                       * numbers
  1040.                       */
  1041.                      BEGIN(INITIAL);
  1042.                      }
  1043.  
  1044.          [0-9]+      {
  1045.                      printf( "found an integer, = %d\n",
  1046.                              atoi( yytext ) );
  1047.                      }
  1048.  
  1049.          "."         printf( "found a dot\n" );
  1050.  
  1051.  
  1052.  
  1053. Version 2.4        Last change: November 1993                  16
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1061.  
  1062.  
  1063.  
  1064.      Here is a scanner which recognizes (and discards) C comments
  1065.      while maintaining a count of the current input line.
  1066.  
  1067.          %x comment
  1068.          %%
  1069.                  int line_num = 1;
  1070.  
  1071.          "/*"         BEGIN(comment);
  1072.  
  1073.          <comment>[^*\n]*        /* eat anything that's not a '*' */
  1074.          <comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
  1075.          <comment>\n             ++line_num;
  1076.          <comment>"*"+"/"        BEGIN(INITIAL);
  1077.  
  1078.      This scanner goes to a bit of trouble to match as much  text
  1079.      as  possible with each rule.  In general, when attempting to
  1080.      write a high-speed scanner try to match as much possible  in
  1081.      each rule, as it's a big win.
  1082.  
  1083.      Note that start-conditions names are really  integer  values
  1084.      and  can  be  stored  as  such.   Thus,  the  above could be
  1085.      extended in the following fashion:
  1086.  
  1087.          %x comment foo
  1088.          %%
  1089.                  int line_num = 1;
  1090.                  int comment_caller;
  1091.  
  1092.          "/*"         {
  1093.                       comment_caller = INITIAL;
  1094.                       BEGIN(comment);
  1095.                       }
  1096.  
  1097.          ...
  1098.  
  1099.          <foo>"/*"    {
  1100.                       comment_caller = foo;
  1101.                       BEGIN(comment);
  1102.                       }
  1103.  
  1104.          <comment>[^*\n]*        /* eat anything that's not a '*' */
  1105.          <comment>"*"+[^*/\n]*   /* eat up '*'s not followed by '/'s */
  1106.          <comment>\n             ++line_num;
  1107.          <comment>"*"+"/"        BEGIN(comment_caller);
  1108.  
  1109.      Furthermore, you can  access  the  current  start  condition
  1110.      using  the  integer-valued YYYYYYYY____SSSSTTTTAAAARRRRTTTT macro.  For example, the
  1111.      above assignments to _c_o_m_m_e_n_t__c_a_l_l_e_r could instead be written
  1112.  
  1113.          comment_caller = YY_START;
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119. Version 2.4        Last change: November 1993                  17
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1127.  
  1128.  
  1129.  
  1130.      Note that start conditions do not have their own name-space;
  1131.      %s's   and  %x's  declare  names  in  the  same  fashion  as
  1132.      #define's.
  1133.  
  1134.      Finally, here's an example of how to  match  C-style  quoted
  1135.      strings using exclusive start conditions, including expanded
  1136.      escape sequences (but not including checking  for  a  string
  1137.      that's too long):
  1138.  
  1139.          %x str
  1140.  
  1141.          %%
  1142.                  char string_buf[MAX_STR_CONST];
  1143.                  char *string_buf_ptr;
  1144.  
  1145.  
  1146.          \"      string_buf_ptr = string_buf; BEGIN(str);
  1147.  
  1148.          <str>\"        { /* saw closing quote - all done */
  1149.                  BEGIN(INITIAL);
  1150.                  *string_buf_ptr = '\0';
  1151.                  /* return string constant token type and
  1152.                   * value to parser
  1153.                   */
  1154.                  }
  1155.  
  1156.          <str>\n        {
  1157.                  /* error - unterminated string constant */
  1158.                  /* generate error message */
  1159.                  }
  1160.  
  1161.          <str>\\[0-7]{1,3} {
  1162.                  /* octal escape sequence */
  1163.                  int result;
  1164.  
  1165.                  (void) sscanf( yytext + 1, "%o", &result );
  1166.  
  1167.                  if ( result > 0xff )
  1168.                          /* error, constant is out-of-bounds */
  1169.  
  1170.                  *string_buf_ptr++ = result;
  1171.                  }
  1172.  
  1173.          <str>\\[0-9]+ {
  1174.                  /* generate error - bad escape sequence; something
  1175.                   * like '\48' or '\0777777'
  1176.                   */
  1177.                  }
  1178.  
  1179.          <str>\\n  *string_buf_ptr++ = '\n';
  1180.          <str>\\t  *string_buf_ptr++ = '\t';
  1181.          <str>\\r  *string_buf_ptr++ = '\r';
  1182.  
  1183.  
  1184.  
  1185. Version 2.4        Last change: November 1993                  18
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1193.  
  1194.  
  1195.  
  1196.          <str>\\b  *string_buf_ptr++ = '\b';
  1197.          <str>\\f  *string_buf_ptr++ = '\f';
  1198.  
  1199.          <str>\\(.|\n)  *string_buf_ptr++ = yytext[1];
  1200.  
  1201.          <str>[^\\\n\"]+        {
  1202.                  char *yytext_ptr = yytext;
  1203.  
  1204.                  while ( *yytext_ptr )
  1205.                          *string_buf_ptr++ = *yytext_ptr++;
  1206.                  }
  1207.  
  1208.  
  1209. MMMMUUUULLLLTTTTIIIIPPPPLLLLEEEE IIIINNNNPPPPUUUUTTTT BBBBUUUUFFFFFFFFEEEERRRRSSSS
  1210.      Some scanners (such as those which support "include"  files)
  1211.      require   reading  from  several  input  streams.   As  _f_l_e_x
  1212.      scanners do a large amount of buffering, one cannot  control
  1213.      where  the  next input will be read from by simply writing a
  1214.      YYYYYYYY____IIIINNNNPPPPUUUUTTTT  which  is  sensitive  to  the  scanning   context.
  1215.      YYYYYYYY____IIIINNNNPPPPUUUUTTTT  is only called when the scanner reaches the end of
  1216.      its buffer, which may be a long time after scanning a state-
  1217.      ment such as an "include" which requires switching the input
  1218.      source.
  1219.  
  1220.      To negotiate  these  sorts  of  problems,  _f_l_e_x  provides  a
  1221.      mechanism  for creating and switching between multiple input
  1222.      buffers.  An input buffer is created by using:
  1223.  
  1224.          YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1225.  
  1226.      which takes a _F_I_L_E pointer and a size and creates  a  buffer
  1227.      associated with the given file and large enough to hold _s_i_z_e
  1228.      characters (when in doubt, use YYYYYYYY____BBBBUUUUFFFF____SSSSIIIIZZZZEEEE  for  the  size).
  1229.      It  returns  a  YYYYYYYY____BBBBUUUUFFFFFFFFEEEERRRR____SSSSTTTTAAAATTTTEEEE  handle,  which  may then be
  1230.      passed to other routines:
  1231.  
  1232.          void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1233.  
  1234.      switches the scanner's input  buffer  so  subsequent  tokens
  1235.      will  come  from _n_e_w__b_u_f_f_e_r. Note that yyyyyyyy____sssswwwwiiiittttcccchhhh____ttttoooo____bbbbuuuuffffffffeeeerrrr(((())))
  1236.      may be used by yywrap() to set things up for continued scan-
  1237.      ning, instead of opening a new file and pointing _y_y_i_n at it.
  1238.  
  1239.          void yy_delete_buffer( YY_BUFFER_STATE buffer )
  1240.  
  1241.      is used to reclaim the storage associated with a buffer.
  1242.  
  1243.      yyyyyyyy____nnnneeeewwww____bbbbuuuuffffffffeeeerrrr(((()))) is an alias for yyyyyyyy____ccccrrrreeeeaaaatttteeee____bbbbuuuuffffffffeeeerrrr(((()))),,,, provided
  1244.      for  compatibility  with  the  C++ use of _n_e_w and _d_e_l_e_t_e for
  1245.      creating and destroying dynamic objects.
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251. Version 2.4        Last change: November 1993                  19
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1259.  
  1260.  
  1261.  
  1262.      Finally,   the    YYYYYYYY____CCCCUUUURRRRRRRREEEENNNNTTTT____BBBBUUUUFFFFFFFFEEEERRRR    macro    returns    a
  1263.      YYYYYYYY____BBBBUUUUFFFFFFFFEEEERRRR____SSSSTTTTAAAATTTTEEEE handle to the current buffer.
  1264.  
  1265.      Here is an example of using these  features  for  writing  a
  1266.      scanner  which expands include files (the <<<<<<<<EEEEOOOOFFFF>>>>>>>> feature is
  1267.      discussed below):
  1268.  
  1269.          /* the "incl" state is used for picking up the name
  1270.           * of an include file
  1271.           */
  1272.          %x incl
  1273.  
  1274.          %{
  1275.          #define MAX_INCLUDE_DEPTH 10
  1276.          YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
  1277.          int include_stack_ptr = 0;
  1278.          %}
  1279.  
  1280.          %%
  1281.          include             BEGIN(incl);
  1282.  
  1283.          [a-z]+              ECHO;
  1284.          [^a-z\n]*\n?        ECHO;
  1285.  
  1286.          <incl>[ \t]*      /* eat the whitespace */
  1287.          <incl>[^ \t\n]+   { /* got the include file name */
  1288.                  if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
  1289.                      {
  1290.                      fprintf( stderr, "Includes nested too deeply" );
  1291.                      exit( 1 );
  1292.                      }
  1293.  
  1294.                  include_stack[include_stack_ptr++] =
  1295.                      YY_CURRENT_BUFFER;
  1296.  
  1297.                  yyin = fopen( yytext, "r" );
  1298.  
  1299.                  if ( ! yyin )
  1300.                      error( ... );
  1301.  
  1302.                  yy_switch_to_buffer(
  1303.                      yy_create_buffer( yyin, YY_BUF_SIZE ) );
  1304.  
  1305.                  BEGIN(INITIAL);
  1306.                  }
  1307.  
  1308.          <<EOF>> {
  1309.                  if ( --include_stack_ptr < 0 )
  1310.                      {
  1311.                      yyterminate();
  1312.                      }
  1313.  
  1314.  
  1315.  
  1316.  
  1317. Version 2.4        Last change: November 1993                  20
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1325.  
  1326.  
  1327.  
  1328.                  else
  1329.                      {
  1330.                      yy_delete_buffer( YY_CURRENT_BUFFER );
  1331.                      yy_switch_to_buffer(
  1332.                           include_stack[include_stack_ptr] );
  1333.                      }
  1334.                  }
  1335.  
  1336.  
  1337. EEEENNNNDDDD----OOOOFFFF----FFFFIIIILLLLEEEE RRRRUUUULLLLEEEESSSS
  1338.      The special rule "<<EOF>>" indicates actions which are to be
  1339.      taken  when  an  end-of-file  is  encountered  and  yywrap()
  1340.      returns non-zero (i.e., indicates no further files  to  pro-
  1341.      cess).  The action must finish by doing one of four things:
  1342.  
  1343.      -    assigning _y_y_i_n to a new input file  (in  previous  ver-
  1344.           sions  of  flex,  after doing the assignment you had to
  1345.           call the special action YYYYYYYY____NNNNEEEEWWWW____FFFFIIIILLLLEEEE;;;; this is no  longer
  1346.           necessary);
  1347.  
  1348.      -    executing a _r_e_t_u_r_n statement;
  1349.  
  1350.      -    executing the special yyyyyyyytttteeeerrrrmmmmiiiinnnnaaaatttteeee(((()))) action;
  1351.  
  1352.      -    or,    switching    to    a    new     buffer     using
  1353.           yyyyyyyy____sssswwwwiiiittttcccchhhh____ttttoooo____bbbbuuuuffffffffeeeerrrr(((()))) as shown in the example above.
  1354.  
  1355.      <<EOF>> rules may not be used with other patterns; they  may
  1356.      only  be  qualified  with a list of start conditions.  If an
  1357.      unqualified <<EOF>> rule is given, it applies to  _a_l_l  start
  1358.      conditions  which  do  not already have <<EOF>> actions.  To
  1359.      specify an <<EOF>> rule for only the  initial  start  condi-
  1360.      tion, use
  1361.  
  1362.          <INITIAL><<EOF>>
  1363.  
  1364.  
  1365.      These rules are useful for  catching  things  like  unclosed
  1366.      comments.  An example:
  1367.  
  1368.          %x quote
  1369.          %%
  1370.  
  1371.          ...other rules for dealing with quotes...
  1372.  
  1373.          <quote><<EOF>>   {
  1374.                   error( "unterminated quote" );
  1375.                   yyterminate();
  1376.                   }
  1377.          <<EOF>>  {
  1378.                   if ( *++filelist )
  1379.                       yyin = fopen( *filelist, "r" );
  1380.  
  1381.  
  1382.  
  1383. Version 2.4        Last change: November 1993                  21
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1391.  
  1392.  
  1393.  
  1394.                   else
  1395.                      yyterminate();
  1396.                   }
  1397.  
  1398.  
  1399. MMMMIIIISSSSCCCCEEEELLLLLLLLAAAANNNNEEEEOOOOUUUUSSSS MMMMAAAACCCCRRRROOOOSSSS
  1400.      The macro YY_USER_ACTION can be defined to provide an action
  1401.      which is always executed prior to the matched rule's action.
  1402.      For example, it could be #define'd to call a routine to con-
  1403.      vert yytext to lower-case.
  1404.  
  1405.      The macro YYYYYYYY____UUUUSSSSEEEERRRR____IIIINNNNIIIITTTT may be defined to provide  an  action
  1406.      which  is  always executed before the first scan (and before
  1407.      the scanner's internal initializations are done).  For exam-
  1408.      ple,  it  could  be used to call a routine to read in a data
  1409.      table or open a logging file.
  1410.  
  1411.      In the generated scanner, the actions are  all  gathered  in
  1412.      one  large  switch  statement  and separated using YYYYYYYY____BBBBRRRREEEEAAAAKKKK,,,,
  1413.      which may be redefined.  By default, it is simply a "break",
  1414.      to  separate  each  rule's action from the following rule's.
  1415.      Redefining  YYYYYYYY____BBBBRRRREEEEAAAAKKKK  allows,  for  example,  C++  users  to
  1416.      #define  YY_BREAK  to  do  nothing (while being very careful
  1417.      that every rule ends with a "break" or a "return"!) to avoid
  1418.      suffering  from unreachable statement warnings where because
  1419.      a rule's action ends with "return", the YYYYYYYY____BBBBRRRREEEEAAAAKKKK is inacces-
  1420.      sible.
  1421.  
  1422. IIIINNNNTTTTEEEERRRRFFFFAAAACCCCIIIINNNNGGGG WWWWIIIITTTTHHHH YYYYAAAACCCCCCCC
  1423.      One of the main uses of _f_l_e_x is as a companion to  the  _y_a_c_c
  1424.      parser-generator.   _y_a_c_c  parsers  expect  to call a routine
  1425.      named yyyyyyyylllleeeexxxx(((()))) to find the next input token.  The routine  is
  1426.      supposed  to  return  the  type of the next token as well as
  1427.      putting any associated value in the global  yyyyyyyyllllvvvvaaaallll....  To  use
  1428.      _f_l_e_x  with  _y_a_c_c,  one  specifies  the  ----dddd option to _y_a_c_c to
  1429.      instruct it to generate the file yyyy....ttttaaaabbbb....hhhh containing  defini-
  1430.      tions  of all the %%%%ttttooookkkkeeeennnnssss appearing in the _y_a_c_c input.  This
  1431.      file is then included in the _f_l_e_x scanner.  For example,  if
  1432.      one of the tokens is "TOK_NUMBER", part of the scanner might
  1433.      look like:
  1434.  
  1435.          %{
  1436.          #include "y.tab.h"
  1437.          %}
  1438.  
  1439.          %%
  1440.  
  1441.          [0-9]+        yylval = atoi( yytext ); return TOK_NUMBER;
  1442.  
  1443.  
  1444. OOOOPPPPTTTTIIIIOOOONNNNSSSS
  1445.      _f_l_e_x has the following options:
  1446.  
  1447.  
  1448.  
  1449. Version 2.4        Last change: November 1993                  22
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1457.  
  1458.  
  1459.  
  1460.      ----bbbb    Generate backing-up information to _l_e_x._b_a_c_k_u_p. This is
  1461.           a  list  of scanner states which require backing up and
  1462.           the input characters on which they do  so.   By  adding
  1463.           rules   one  can  remove  backing-up  states.   If  all
  1464.           backing-up states are eliminated and ----CCCCffff  or   ---- CCCCFFFF  is
  1465.           used, the generated scanner will run faster (see the ----pppp
  1466.           flag).  Only users who wish to squeeze every last cycle
  1467.           out  of  their  scanners  need worry about this option.
  1468.           (See the section on Performance Considerations below.)
  1469.  
  1470.      ----cccc    is a do-nothing, deprecated option included for  POSIX
  1471.           compliance.
  1472.  
  1473.           NNNNOOOOTTTTEEEE:::: in previous releases of _f_l_e_x ----cccc specified  table-
  1474.           compression  options.   This functionality is now given
  1475.           by the ----CCCC flag.  To ease the the impact of this change,
  1476.           when  _f_l_e_x encounters ----cccc,,,, it currently issues a warning
  1477.           message and assumes that ----CCCC was  desired  instead.   In
  1478.           the future this "promotion" of ----cccc to ----CCCC will go away in
  1479.           the name of full POSIX  compliance  (unless  the  POSIX
  1480.           meaning is removed first).
  1481.  
  1482.      ----dddd    makes the generated scanner run in _d_e_b_u_g mode.   When-
  1483.           ever   a   pattern   is   recognized   and  the  global
  1484.           yyyyyyyy____fffflllleeeexxxx____ddddeeeebbbbuuuugggg is non-zero (which is the  default),  the
  1485.           scanner will write to _s_t_d_e_r_r a line of the form:
  1486.  
  1487.               --accepting rule at line 53 ("the matched text")
  1488.  
  1489.           The line number refers to the location of the  rule  in
  1490.           the  file defining the scanner (i.e., the file that was
  1491.           fed to flex).  Messages are  also  generated  when  the
  1492.           scanner backs up, accepts the default rule, reaches the
  1493.           end of its input buffer (or encounters a NUL;  at  this
  1494.           point,  the  two  look the same as far as the scanner's
  1495.           concerned), or reaches an end-of-file.
  1496.  
  1497.      ----ffff    specifies _f_a_s_t _s_c_a_n_n_e_r. No table compression  is  done
  1498.           and  stdio  is bypassed.  The result is large but fast.
  1499.           This option is equivalent to ----CCCCffffrrrr (see below).
  1500.  
  1501.      ----hhhh    generates a "help" summary of _f_l_e_x'_s options to _s_t_d_e_r_r
  1502.           and then exits.
  1503.  
  1504.      ----iiii    instructs _f_l_e_x to generate a _c_a_s_e-_i_n_s_e_n_s_i_t_i_v_e scanner.
  1505.           The  case  of  letters given in the _f_l_e_x input patterns
  1506.           will be ignored,  and  tokens  in  the  input  will  be
  1507.           matched  regardless of case.  The matched text given in
  1508.           _y_y_t_e_x_t will have the preserved case (i.e., it will  not
  1509.           be folded).
  1510.  
  1511.      ----llll    turns on maximum compatibility with the original  AT&T
  1512.  
  1513.  
  1514.  
  1515. Version 2.4        Last change: November 1993                  23
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1523.  
  1524.  
  1525.  
  1526.           _l_e_x  implementation.  Note that this does not mean _f_u_l_l
  1527.           compatibility.  Use of this option costs a considerable
  1528.           amount of performance, and it cannot be used with the ----
  1529.           ++++,,,, ----ffff,,,, ----FFFF,,,, ----CCCCffff,,,, or ----CCCCFFFF options.   For  details  on  the
  1530.           compatibilities  it provides, see the section "Incompa-
  1531.           tibilities With Lex And POSIX" below.
  1532.  
  1533.      ----nnnn    is another do-nothing, deprecated option included only
  1534.           for POSIX compliance.
  1535.  
  1536.      ----pppp    generates a performance report to stderr.  The  report
  1537.           consists  of  comments  regarding  features of the _f_l_e_x
  1538.           input file which will cause a serious loss  of  perfor-
  1539.           mance  in  the resulting scanner.  If you give the flag
  1540.           twice, you will also get  comments  regarding  features
  1541.           that lead to minor performance losses.
  1542.  
  1543.           Note that the use of RRRREEEEJJJJEEEECCCCTTTT and variable trailing  con-
  1544.           text  (see  the Bugs section in flex(1)) entails a sub-
  1545.           stantial performance penalty; use of  _y_y_m_o_r_e(),  the  ^^^^
  1546.           operator,  and  the   ---- IIII flag entail minor performance
  1547.           penalties.
  1548.  
  1549.      ----ssss    causes the _d_e_f_a_u_l_t _r_u_l_e (that unmatched scanner  input
  1550.           is  echoed to _s_t_d_o_u_t) to be suppressed.  If the scanner
  1551.           encounters input that does not match any of its  rules,
  1552.           it  aborts  with  an  error.  This option is useful for
  1553.           finding holes in a scanner's rule set.
  1554.  
  1555.      ----tttt    instructs _f_l_e_x to write the scanner  it  generates  to
  1556.           standard output instead of lllleeeexxxx....yyyyyyyy....cccc....
  1557.  
  1558.      ----vvvv    specifies that _f_l_e_x should write to _s_t_d_e_r_r  a  summary
  1559.           of statistics regarding the scanner it generates.  Most
  1560.           of the statistics are meaningless to  the  casual  _f_l_e_x
  1561.           user, but the first line identifies the version of _f_l_e_x
  1562.           (same as reported by ----VVVV)))),,,, and the next line  the  flags
  1563.           used  when generating the scanner, including those that
  1564.           are on by default.
  1565.  
  1566.      ----wwww    suppresses warning messages.
  1567.  
  1568.      ----BBBB    instructs _f_l_e_x to generate a _b_a_t_c_h scanner, the  oppo-
  1569.           site  of  _i_n_t_e_r_a_c_t_i_v_e  scanners  generated  by  ----IIII (see
  1570.           below).  In general, you use ----BBBB when  you  are  _c_e_r_t_a_i_n
  1571.           that your scanner will never be used interactively, and
  1572.           you want to squeeze a _l_i_t_t_l_e more  performance  out  of
  1573.           it.   If your goal is instead to squeeze out a _l_o_t more
  1574.           performance, you should  be using the   ---- CCCCffff  or   ---- CCCCFFFF
  1575.           options  (discussed  below), which turn on ----BBBB automati-
  1576.           cally anyway.
  1577.  
  1578.  
  1579.  
  1580.  
  1581. Version 2.4        Last change: November 1993                  24
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1589.  
  1590.  
  1591.  
  1592.      ----FFFF    specifies that the _f_a_s_t scanner  table  representation
  1593.           should  be used (and stdio bypassed).  This representa-
  1594.           tion is about as fast as the full table  representation
  1595.           ((((----ffff)))),,,,  and  for some sets of patterns will be consider-
  1596.           ably smaller (and for others, larger).  In general,  if
  1597.           the  pattern  set contains both "keywords" and a catch-
  1598.           all, "identifier" rule, such as in the set:
  1599.  
  1600.               "case"    return TOK_CASE;
  1601.               "switch"  return TOK_SWITCH;
  1602.               ...
  1603.               "default" return TOK_DEFAULT;
  1604.               [a-z]+    return TOK_ID;
  1605.  
  1606.           then you're better off using the full table representa-
  1607.           tion.  If only the "identifier" rule is present and you
  1608.           then use a hash table or some such to detect  the  key-
  1609.           words, you're better off using ----FFFF....
  1610.  
  1611.           This option is equivalent to ----CCCCFFFFrrrr (see below).  It can-
  1612.           not be used with ----++++....
  1613.  
  1614.      ----IIII    instructs _f_l_e_x to generate an _i_n_t_e_r_a_c_t_i_v_e scanner.  An
  1615.           interactive  scanner  is  one  that only looks ahead to
  1616.           decide what token has been  matched  if  it  absolutely
  1617.           must.  It turns out that always looking one extra char-
  1618.           acter ahead, even  if  the  scanner  has  already  seen
  1619.           enough text to disambiguate the current token, is a bit
  1620.           faster than only looking  ahead  when  necessary.   But
  1621.           scanners  that always look ahead give dreadful interac-
  1622.           tive performance; for example, when a user types a new-
  1623.           line,  it  is  not  recognized as a newline token until
  1624.           they enter _a_n_o_t_h_e_r token, which often means  typing  in
  1625.           another whole line.
  1626.  
  1627.           _F_l_e_x scanners default to _i_n_t_e_r_a_c_t_i_v_e unless you use the
  1628.            ---- CCCCffff  or   ---- CCCCFFFF table-compression options (see below).
  1629.           That's because if you're looking  for  high-performance
  1630.           you  should  be  using  one of these options, so if you
  1631.           didn't, _f_l_e_x assumes you'd rather trade off  a  bit  of
  1632.           run-time    performance   for   intuitive   interactive
  1633.           behavior.  Note also that you _c_a_n_n_o_t use ----IIII in conjunc-
  1634.           tion  with  ----CCCCffff or ----CCCCFFFF.... Thus, this option is not really
  1635.           needed; it is on by default  for  all  those  cases  in
  1636.           which it is allowed.
  1637.  
  1638.           You can force a scanner to _n_o_t be interactive by using
  1639.           ----BBBB (see above).
  1640.  
  1641.      ----LLLL    instructs  _f_l_e_x  not  to  generate  ####lllliiiinnnneeee  directives.
  1642.           Without this option, _f_l_e_x peppers the generated scanner
  1643.           with #line directives so error messages in the  actions
  1644.  
  1645.  
  1646.  
  1647. Version 2.4        Last change: November 1993                  25
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1655.  
  1656.  
  1657.  
  1658.           will  be correctly located with respect to the original
  1659.           _f_l_e_x input file, and not to the fairly meaningless line
  1660.           numbers  of  lllleeeexxxx....yyyyyyyy....cccc....  (Unfortunately  _f_l_e_x  does  not
  1661.           presently generate the necessary directives to  "retar-
  1662.           get" the line numbers for those parts of lllleeeexxxx....yyyyyyyy....cccc which
  1663.           it generated.  So if there is an error in the generated
  1664.           code, a meaningless line number is reported.)
  1665.  
  1666.      ----TTTT    makes _f_l_e_x run in _t_r_a_c_e mode.  It will generate a  lot
  1667.           of  messages to _s_t_d_e_r_r concerning the form of the input
  1668.           and the resultant non-deterministic  and  deterministic
  1669.           finite  automata.   This  option  is  mostly for use in
  1670.           maintaining _f_l_e_x.
  1671.  
  1672.      ----VVVV    prints the version number to _s_t_d_e_r_r and exits.
  1673.  
  1674.      ----7777    instructs _f_l_e_x to generate a 7-bit scanner, i.e.,  one
  1675.           which  can  only  recognized  7-bit  characters  in its
  1676.           input.  The advantage of using ----7777 is that the scanner's
  1677.           tables  can  be  up to half the size of those generated
  1678.           using the ----8888 option (see below).  The  disadvantage  is
  1679.           that  such  scanners often hang or crash if their input
  1680.           contains an 8-bit character.
  1681.  
  1682.           Note, however, that unless you  generate  your  scanner
  1683.           using the ----CCCCffff or ----CCCCFFFF table compression options, use of
  1684.           ----7777 will save only a small amount of  table  space,  and
  1685.           make  your  scanner considerably less portable.  _F_l_e_x'_s
  1686.           default behavior is to generate an 8-bit scanner unless
  1687.           you  use the ----CCCCffff or ----CCCCFFFF,,,, in which case _f_l_e_x defaults to
  1688.           generating 7-bit scanners unless your site  was  always
  1689.           configured to generate 8-bit scanners (as will often be
  1690.           the case with non-USA sites).   You  can  tell  whether
  1691.           flex  generated a 7-bit or an 8-bit scanner by inspect-
  1692.           ing the flag summary in the  ---- vvvv  output  as  described
  1693.           above.
  1694.  
  1695.           Note that if you use ----CCCCffffeeee or ----CCCCFFFFeeee (those table compres-
  1696.           sion  options,  but  also  using equivalence classes as
  1697.           discussed see below), flex still defaults to generating
  1698.           an  8-bit scanner, since usually with these compression
  1699.           options full 8-bit tables are not much  more  expensive
  1700.           than 7-bit tables.
  1701.  
  1702.      ----8888    instructs _f_l_e_x to generate an 8-bit scanner, i.e., one
  1703.           which  can  recognize  8-bit  characters.  This flag is
  1704.           only needed for scanners generated using ----CCCCffff or ----CCCCFFFF,,,, as
  1705.           otherwise  flex defaults to generating an 8-bit scanner
  1706.           anyway.
  1707.  
  1708.           See the discussion of  ---- 7777  above  for  flex's  default
  1709.           behavior  and  the  tradeoffs  between  7-bit and 8-bit
  1710.  
  1711.  
  1712.  
  1713. Version 2.4        Last change: November 1993                  26
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1721.  
  1722.  
  1723.  
  1724.           scanners.
  1725.  
  1726.      ----++++    specifies that you want flex to generate a C++ scanner
  1727.           class.   See  the  section  on  Generating C++ Scanners
  1728.           below for details.
  1729.  
  1730.      ----CCCC[[[[aaaaeeeeffffFFFFmmmmrrrr]]]]
  1731.           controls the degree of table compression and, more gen-
  1732.           erally,  trade-offs  between  small  scanners  and fast
  1733.           scanners.
  1734.  
  1735.           ----CCCCaaaa ("align") instructs flex to trade off larger tables
  1736.           in the generated scanner for faster performance because
  1737.           the elements of  the  tables  are  better  aligned  for
  1738.           memory  access and computation.  On some RISC architec-
  1739.           tures, fetching  and  manipulating  longwords  is  more
  1740.           efficient than with smaller-sized datums such as short-
  1741.           words.  This option can double the size of  the  tables
  1742.           used by your scanner.
  1743.  
  1744.           ----CCCCeeee directs  _f_l_e_x  to  construct  _e_q_u_i_v_a_l_e_n_c_e  _c_l_a_s_s_e_s,
  1745.           i.e.,  sets  of characters which have identical lexical
  1746.           properties (for example,  if  the  only  appearance  of
  1747.           digits  in  the  _f_l_e_x  input  is in the character class
  1748.           "[0-9]" then the digits '0', '1', ..., '9' will all  be
  1749.           put   in  the  same  equivalence  class).   Equivalence
  1750.           classes usually give dramatic reductions in  the  final
  1751.           table/object file sizes (typically a factor of 2-5) and
  1752.           are pretty cheap performance-wise  (one  array  look-up
  1753.           per character scanned).
  1754.  
  1755.           ----CCCCffff specifies that the _f_u_l_l scanner  tables  should  be
  1756.           generated - _f_l_e_x should not compress the tables by tak-
  1757.           ing advantages of similar transition functions for dif-
  1758.           ferent states.
  1759.  
  1760.           ----CCCCFFFF specifies that the alternate fast scanner represen-
  1761.           tation  (described  above  under the ----FFFF flag) should be
  1762.           used.  This option cannot be used with ----++++....
  1763.  
  1764.           ----CCCCmmmm directs _f_l_e_x to construct _m_e_t_a-_e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s_e_s,
  1765.           which  are  sets of equivalence classes (or characters,
  1766.           if equivalence classes are not  being  used)  that  are
  1767.           commonly  used  together.  Meta-equivalence classes are
  1768.           often a big win when using compressed tables, but  they
  1769.           have  a  moderate  performance  impact (one or two "if"
  1770.           tests and one array look-up per character scanned).
  1771.  
  1772.           ----CCCCrrrr causes the generated scanner to _b_y_p_a_s_s use  of  the
  1773.           standard  I/O  library  (stdio)  for input.  Instead of
  1774.           calling ffffrrrreeeeaaaadddd(((()))) or ggggeeeettttcccc(((()))),,,, the  scanner  will  use  the
  1775.           rrrreeeeaaaadddd(((())))  system  call,  resulting  in a performance gain
  1776.  
  1777.  
  1778.  
  1779. Version 2.4        Last change: November 1993                  27
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1787.  
  1788.  
  1789.  
  1790.           which varies from system to system, but in  general  is
  1791.           probably  negligible unless you are also using ----CCCCffff or ----
  1792.           CCCCFFFF.... Using ----CCCCrrrr can cause strange behavior if, for  exam-
  1793.           ple,  you  read  from _y_y_i_n using stdio prior to calling
  1794.           the scanner (because the  scanner  will  miss  whatever
  1795.           text  your  previous  reads  left  in  the  stdio input
  1796.           buffer).
  1797.  
  1798.           ----CCCCrrrr has no effect if you define YYYYYYYY____IIIINNNNPPPPUUUUTTTT (see The  Gen-
  1799.           erated Scanner above).
  1800.  
  1801.           A lone ----CCCC specifies that the scanner tables  should  be
  1802.           compressed  but  neither  equivalence classes nor meta-
  1803.           equivalence classes should be used.
  1804.  
  1805.           The options ----CCCCffff or ----CCCCFFFF and   ---- CCCCmmmm  do  not  make  sense
  1806.           together - there is no opportunity for meta-equivalence
  1807.           classes if the table is not being  compressed.   Other-
  1808.           wise  the  options may be freely mixed, and are cumula-
  1809.           tive.
  1810.  
  1811.           The default setting is ----CCCCeeeemmmm,,,, which specifies that  _f_l_e_x
  1812.           should   generate   equivalence   classes   and   meta-
  1813.           equivalence classes.  This setting provides the highest
  1814.           degree   of  table  compression.   You  can  trade  off
  1815.           faster-executing scanners at the cost of larger  tables
  1816.           with the following generally being true:
  1817.  
  1818.               slowest & smallest
  1819.                     -Cem
  1820.                     -Cm
  1821.                     -Ce
  1822.                     -C
  1823.                     -C{f,F}e
  1824.                     -C{f,F}
  1825.                     -C{f,F}a
  1826.               fastest & largest
  1827.  
  1828.           Note that scanners with the smallest tables are usually
  1829.           generated and compiled the quickest, so during develop-
  1830.           ment you will usually want to use the default,  maximal
  1831.           compression.
  1832.  
  1833.           ----CCCCffffeeee is often a good compromise between speed and  size
  1834.           for production scanners.
  1835.  
  1836.      ----PPPPpppprrrreeeeffffiiiixxxx
  1837.           changes the default _y_y prefix  used  by  _f_l_e_x  for  all
  1838.           globally-visible variable and function names to instead
  1839.           be _p_r_e_f_i_x. For example,  ---- PPPPffffoooooooo  changes  the  name  of
  1840.           yyyyyyyytttteeeexxxxtttt  to  ffffooooooootttteeeexxxxtttt....  It  also  changes the name of the
  1841.           default output file from lllleeeexxxx....yyyyyyyy....cccc  to  lllleeeexxxx....ffffoooooooo....cccc....  Here
  1842.  
  1843.  
  1844.  
  1845. Version 2.4        Last change: November 1993                  28
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1853.  
  1854.  
  1855.  
  1856.           are all of the names affected:
  1857.  
  1858.               yyFlexLexer
  1859.               yy_create_buffer
  1860.               yy_delete_buffer
  1861.               yy_flex_debug
  1862.               yy_init_buffer
  1863.               yy_load_buffer_state
  1864.               yy_switch_to_buffer
  1865.               yyin
  1866.               yyleng
  1867.               yylex
  1868.               yyout
  1869.               yyrestart
  1870.               yytext
  1871.               yywrap
  1872.  
  1873.           Within your scanner itself, you can still refer to  the
  1874.           global  variables and functions using either version of
  1875.           their name; but eternally, they have the modified name.
  1876.  
  1877.           This option lets you easily link together multiple _f_l_e_x
  1878.           programs  into the same executable.  Note, though, that
  1879.           using this option also renames  yyyyyyyywwwwrrrraaaapppp(((()))),,,,  so  you  now
  1880.           _m_u_s_t  provide your own (appropriately-named) version of
  1881.           the routine for your scanner, as linking with ---- llllffffllll  no
  1882.           longer provides one for you by default.
  1883.  
  1884.      ----SSSSsssskkkkeeeelllleeeettttoooonnnn____ffffiiiilllleeee
  1885.           overrides the default skeleton  file  from  which  _f_l_e_x
  1886.           constructs its scanners.  You'll never need this option
  1887.           unless you are doing _f_l_e_x maintenance or development.
  1888.  
  1889. PPPPEEEERRRRFFFFOOOORRRRMMMMAAAANNNNCCCCEEEE CCCCOOOONNNNSSSSIIIIDDDDEEEERRRRAAAATTTTIIIIOOOONNNNSSSS
  1890.      The main design goal of  _f_l_e_x  is  that  it  generate  high-
  1891.      performance  scanners.   It  has  been optimized for dealing
  1892.      well with large sets of rules.  Aside from  the  effects  on
  1893.      scanner  speed  of the table compression ----CCCC options outlined
  1894.      above, there are a number of options/actions  which  degrade
  1895.      performance.  These are, from most expensive to least:
  1896.  
  1897.          REJECT
  1898.  
  1899.          pattern sets that require backing up
  1900.          arbitrary trailing context
  1901.  
  1902.          yymore()
  1903.          '^' beginning-of-line operator
  1904.  
  1905.      with the first three all being quite expensive and the  last
  1906.      two  being  quite  cheap.   Note also that uuuunnnnppppuuuutttt(((()))) is imple-
  1907.      mented as a routine call that potentially does quite  a  bit
  1908.  
  1909.  
  1910.  
  1911. Version 2.4        Last change: November 1993                  29
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1919.  
  1920.  
  1921.  
  1922.      of  work,  while yyyyyyyylllleeeessssssss(((()))) is a quite-cheap macro; so if just
  1923.      putting back some excess text you scanned, use yyyyyyyylllleeeessssssss(((())))....
  1924.  
  1925.      RRRREEEEJJJJEEEECCCCTTTT should be avoided at all costs  when  performance  is
  1926.      important.  It is a particularly expensive option.
  1927.  
  1928.      Getting rid of backing up is messy and often may be an enor-
  1929.      mous  amount  of work for a complicated scanner.  In princi-
  1930.      pal, one begins  by  using  the   ---- bbbb  flag  to  generate  a
  1931.      _l_e_x._b_a_c_k_u_p file.  For example, on the input
  1932.  
  1933.          %%
  1934.          foo        return TOK_KEYWORD;
  1935.          foobar     return TOK_KEYWORD;
  1936.  
  1937.      the file looks like:
  1938.  
  1939.          State #6 is non-accepting -
  1940.           associated rule line numbers:
  1941.                 2       3
  1942.           out-transitions: [ o ]
  1943.           jam-transitions: EOF [ \001-n  p-\177 ]
  1944.  
  1945.          State #8 is non-accepting -
  1946.           associated rule line numbers:
  1947.                 3
  1948.           out-transitions: [ a ]
  1949.           jam-transitions: EOF [ \001-`  b-\177 ]
  1950.  
  1951.          State #9 is non-accepting -
  1952.           associated rule line numbers:
  1953.                 3
  1954.           out-transitions: [ r ]
  1955.           jam-transitions: EOF [ \001-q  s-\177 ]
  1956.  
  1957.          Compressed tables always back up.
  1958.  
  1959.      The first few lines tell us that there's a scanner state  in
  1960.      which  it  can  make  a  transition on an 'o' but not on any
  1961.      other character,  and  that  in  that  state  the  currently
  1962.      scanned text does not match any rule.  The state occurs when
  1963.      trying to match the rules found at lines  2  and  3  in  the
  1964.      input  file.  If the scanner is in that state and then reads
  1965.      something other than an 'o', it will have to back up to find
  1966.      a  rule  which is matched.  With a bit of headscratching one
  1967.      can see that this must be the state it's in when it has seen
  1968.      "fo".   When  this  has  happened,  if  anything  other than
  1969.      another 'o' is seen, the scanner will have  to  back  up  to
  1970.      simply match the 'f' (by the default rule).
  1971.  
  1972.      The comment regarding State #8 indicates there's  a  problem
  1973.      when  "foob"  has  been  scanned.   Indeed, on any character
  1974.  
  1975.  
  1976.  
  1977. Version 2.4        Last change: November 1993                  30
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. FLEXDOC(1)                User Commands                FLEXDOC(1)
  1985.  
  1986.  
  1987.  
  1988.      other than an 'a', the scanner  will  have  to  back  up  to
  1989.      accept  "foo".  Similarly, the comment for State #9 concerns
  1990.      when "fooba" has been scanned and an 'r' does not follow.
  1991.  
  1992.      The final comment reminds us that there's no point going  to
  1993.      all the trouble of removing backing up from the rules unless
  1994.      we're using ----CCCCffff or ----CCCCFFFF,,,, since there's  no  performance  gain
  1995.      doing so with compressed scanners.
  1996.  
  1997.      The way to remove the backing up is to add "error" rules:
  1998.  
  1999.          %%
  2000.          foo         return TOK_KEYWORD;
  2001.          foobar      return TOK_KEYWORD;
  2002.  
  2003.          fooba       |
  2004.          foob        |
  2005.          fo          {
  2006.                      /* false alarm, not really a keyword */
  2007.                      return TOK_ID;
  2008.                      }
  2009.  
  2010.  
  2011.      Eliminating backing up among a list of keywords can also  be
  2012.      done using a "catch-all" rule:
  2013.  
  2014.          %%
  2015.          foo         return TOK_KEYWORD;
  2016.          foobar      return TOK_KEYWORD;
  2017.  
  2018.          [a-z]+      return TOK_ID;
  2019.  
  2020.      This is usually the best solution when appropriate.
  2021.  
  2022.      Backing up messages tend to cascade.  With a complicated set
  2023.      of  rules it's not uncommon to get hundreds of messages.  If
  2024.      one can decipher them, though, it often only takes  a  dozen
  2025.      or so rules to eliminate the backing up (though it's easy to
  2026.      make a mistake and have an error rule accidentally  match  a
  2027.      valid  token.   A  possible  future  _f_l_e_x feature will be to
  2028.      automatically add rules to eliminate backing up).
  2029.  
  2030.      _V_a_r_i_a_b_l_e trailing context (where both the leading and trail-
  2031.      ing  parts  do  not  have a fixed length) entails almost the
  2032.      same performance loss as  RRRREEEEJJJJEEEECCCCTTTT  (i.e.,  substantial).   So
  2033.      when possible a rule like:
  2034.  
  2035.          %%
  2036.          mouse|rat/(cat|dog)   run();
  2037.  
  2038.      is better written:
  2039.  
  2040.  
  2041.  
  2042.  
  2043. Version 2.4        Last change: November 1993                  31
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2051.  
  2052.  
  2053.  
  2054.          %%
  2055.          mouse/cat|dog         run();
  2056.          rat/cat|dog           run();
  2057.  
  2058.      or as
  2059.  
  2060.          %%
  2061.          mouse|rat/cat         run();
  2062.          mouse|rat/dog         run();
  2063.  
  2064.      Note that here the special '|' action does _n_o_t  provide  any
  2065.      savings, and can even make things worse (see
  2066.  
  2067.      A final note regarding performance: as  mentioned  above  in
  2068.      the  section  How the Input is Matched, dynamically resizing
  2069.      yyyyyyyytttteeeexxxxtttt to accomodate huge tokens is a slow  process  because
  2070.      it  presently  requires  that  the (huge) token be rescanned
  2071.      from the beginning.   Thus  if  performance  is  vital,  you
  2072.      should  attempt  to match "large" quantities of text but not
  2073.      "huge" quantities, where the cutoff between the  two  is  at
  2074.      about 8K characters/token.
  2075.  
  2076.      Another area where the user can increase a scanner's perfor-
  2077.      mance  (and  one that's easier to implement) arises from the
  2078.      fact that the longer the  tokens  matched,  the  faster  the
  2079.      scanner will run.  This is because with long tokens the pro-
  2080.      cessing of most input characters takes place in the  (short)
  2081.      inner  scanning  loop, and does not often have to go through
  2082.      the additional work of setting up the  scanning  environment
  2083.      (e.g.,  yyyyyyyytttteeeexxxxtttt))))  for  the  action.  Recall the scanner for C
  2084.      comments:
  2085.  
  2086.          %x comment
  2087.          %%
  2088.                  int line_num = 1;
  2089.  
  2090.          "/*"         BEGIN(comment);
  2091.  
  2092.          <comment>[^*\n]*
  2093.          <comment>"*"+[^*/\n]*
  2094.          <comment>\n             ++line_num;
  2095.          <comment>"*"+"/"        BEGIN(INITIAL);
  2096.  
  2097.      This could be sped up by writing it as:
  2098.  
  2099.          %x comment
  2100.          %%
  2101.                  int line_num = 1;
  2102.  
  2103.          "/*"         BEGIN(comment);
  2104.  
  2105.          <comment>[^*\n]*
  2106.  
  2107.  
  2108.  
  2109. Version 2.4        Last change: November 1993                  32
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2117.  
  2118.  
  2119.  
  2120.          <comment>[^*\n]*\n      ++line_num;
  2121.          <comment>"*"+[^*/\n]*
  2122.          <comment>"*"+[^*/\n]*\n ++line_num;
  2123.          <comment>"*"+"/"        BEGIN(INITIAL);
  2124.  
  2125.      Now instead of each  newline  requiring  the  processing  of
  2126.      another  action,  recognizing  the newlines is "distributed"
  2127.      over the other rules to keep the matched  text  as  long  as
  2128.      possible.   Note  that  _a_d_d_i_n_g  rules does _n_o_t slow down the
  2129.      scanner!  The speed of the scanner  is  independent  of  the
  2130.      number  of  rules or (modulo the considerations given at the
  2131.      beginning of this section) how  complicated  the  rules  are
  2132.      with regard to operators such as '*' and '|'.
  2133.  
  2134.      A final example in speeding up a scanner: suppose  you  want
  2135.      to  scan through a file containing identifiers and keywords,
  2136.      one per line and with no other  extraneous  characters,  and
  2137.      recognize all the keywords.  A natural first approach is:
  2138.  
  2139.          %%
  2140.          asm      |
  2141.          auto     |
  2142.          break    |
  2143.          ... etc ...
  2144.          volatile |
  2145.          while    /* it's a keyword */
  2146.  
  2147.          .|\n     /* it's not a keyword */
  2148.  
  2149.      To eliminate the back-tracking, introduce a catch-all rule:
  2150.  
  2151.          %%
  2152.          asm      |
  2153.          auto     |
  2154.          break    |
  2155.          ... etc ...
  2156.          volatile |
  2157.          while    /* it's a keyword */
  2158.  
  2159.          [a-z]+   |
  2160.          .|\n     /* it's not a keyword */
  2161.  
  2162.      Now, if it's guaranteed that there's exactly  one  word  per
  2163.      line,  then  we  can reduce the total number of matches by a
  2164.      half by merging in the recognition of newlines with that  of
  2165.      the other tokens:
  2166.  
  2167.          %%
  2168.          asm\n    |
  2169.          auto\n   |
  2170.          break\n  |
  2171.          ... etc ...
  2172.  
  2173.  
  2174.  
  2175. Version 2.4        Last change: November 1993                  33
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2183.  
  2184.  
  2185.  
  2186.          volatile\n |
  2187.          while\n  /* it's a keyword */
  2188.  
  2189.          [a-z]+\n |
  2190.          .|\n     /* it's not a keyword */
  2191.  
  2192.      One has to be careful here,  as  we  have  now  reintroduced
  2193.      backing  up  into the scanner.  In particular, while _w_e know
  2194.      that there will never be any characters in the input  stream
  2195.      other  than letters or newlines, _f_l_e_x can't figure this out,
  2196.      and it will plan for possibly needing to back up when it has
  2197.      scanned  a  token like "auto" and then the next character is
  2198.      something other than a newline or a letter.   Previously  it
  2199.      would  then  just match the "auto" rule and be done, but now
  2200.      it has no "auto" rule, only a "auto\n" rule.   To  eliminate
  2201.      the possibility of backing up, we could either duplicate all
  2202.      rules but without final newlines, or, since we never  expect
  2203.      to  encounter  such  an  input  and therefore don't how it's
  2204.      classified, we can introduce one more catch-all  rule,  this
  2205.      one which doesn't include a newline:
  2206.  
  2207.          %%
  2208.          asm\n    |
  2209.          auto\n   |
  2210.          break\n  |
  2211.          ... etc ...
  2212.          volatile\n |
  2213.          while\n  /* it's a keyword */
  2214.  
  2215.          [a-z]+\n |
  2216.          [a-z]+   |
  2217.          .|\n     /* it's not a keyword */
  2218.  
  2219.      Compiled with ----CCCCffff,,,, this is about as fast as one  can  get  a
  2220.      _f_l_e_x scanner to go for this particular problem.
  2221.  
  2222.      A final note:  _f_l_e_x is slow when  matching  NUL's,  particu-
  2223.      larly  when  a  token contains multiple NUL's.  It's best to
  2224.      write rules which match _s_h_o_r_t amounts of text if it's  anti-
  2225.      cipated that the text will often include NUL's.
  2226.  
  2227. GGGGEEEENNNNEEEERRRRAAAATTTTIIIINNNNGGGG CCCC++++++++ SSSSCCCCAAAANNNNNNNNEEEERRRRSSSS
  2228.      _f_l_e_x provides two different ways to  generate  scanners  for
  2229.      use  with C++.  The first way is to simply compile a scanner
  2230.      generated by _f_l_e_x using a C++ compiler instead of a  C  com-
  2231.      piler.   You  should  not  encounter any compilations errors
  2232.      (please report any you find to the email  address  given  in
  2233.      the  Author  section  below).   You can then use C++ code in
  2234.      your rule actions instead of C code.  Note that the  default
  2235.      input  source  for  your  scanner  remains _y_y_i_n, and default
  2236.      echoing is still done to _y_y_o_u_t. Both of these remain _F_I_L_E  *
  2237.      variables and not C++ _s_t_r_e_a_m_s.
  2238.  
  2239.  
  2240.  
  2241. Version 2.4        Last change: November 1993                  34
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2249.  
  2250.  
  2251.  
  2252.      You can also use _f_l_e_x to generate a C++ scanner class, using
  2253.      the  ----++++ option, which is automatically specified if the name
  2254.      of the flex executable ends in a '+', such as  _f_l_e_x++.  When
  2255.      using  this  option, flex defaults to generating the scanner
  2256.      to the file lllleeeexxxx....yyyyyyyy....cccccccc instead  of  lllleeeexxxx....yyyyyyyy....cccc....  The  generated
  2257.      scanner  includes the header file _F_l_e_x_L_e_x_e_r._h, which defines
  2258.      the interface to two C++ classes.
  2259.  
  2260.      The first class, FFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr,,,, provides an abstract base  class
  2261.      defining  the  general scanner class interface.  It provides
  2262.      the following member functions:
  2263.  
  2264.      ccccoooonnnnsssstttt cccchhhhaaaarrrr**** YYYYYYYYTTTTeeeexxxxtttt(((())))
  2265.           returns the text of the most  recently  matched  token,
  2266.           the equivalent of yyyyyyyytttteeeexxxxtttt....
  2267.  
  2268.      iiiinnnntttt YYYYYYYYLLLLeeeennnngggg(((())))
  2269.           returns the length of the most recently matched  token,
  2270.           the equivalent of yyyyyyyylllleeeennnngggg....
  2271.  
  2272.      Also   provided   are   member   functions   equivalent   to
  2273.      yyyyyyyy____sssswwwwiiiittttcccchhhh____ttttoooo____bbbbuuuuffffffffeeeerrrr(((()))),,,,  yyyyyyyy____ccccrrrreeeeaaaatttteeee____bbbbuuuuffffffffeeeerrrr(((()))) (though the first
  2274.      argument is an iiiissssttttrrrreeeeaaaammmm**** object pointer  and  not  a  FFFFIIIILLLLEEEE****)))),,,,
  2275.      yyyyyyyy____ddddeeeelllleeeetttteeee____bbbbuuuuffffffffeeeerrrr(((()))),,,,  and yyyyyyyyrrrreeeessssttttaaaarrrrtttt(((()))) (again, the first argu-
  2276.      ment is a iiiissssttttrrrreeeeaaaammmm**** object pointer).
  2277.  
  2278.      The second class  defined  in  _F_l_e_x_L_e_x_e_r._h  is  yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr,,,,
  2279.      which  is  derived  from FFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr.... It defines the following
  2280.      additional member functions:
  2281.  
  2282.      yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr(((( iiiissssttttrrrreeeeaaaammmm**** aaaarrrrgggg____yyyyyyyyiiiinnnn ==== 0000,,,, oooossssttttrrrreeeeaaaammmm**** aaaarrrrgggg____yyyyyyyyoooouuuutttt ==== 0000 ))))
  2283.           constructs a yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr object using the given streams
  2284.           for  input  and  output.  If not specified, the streams
  2285.           default to cccciiiinnnn and ccccoooouuuutttt,,,, respectively.
  2286.  
  2287.      vvvviiiirrrrttttuuuuaaaallll iiiinnnntttt yyyyyyyylllleeeexxxx(((())))
  2288.           performs the same role is  yyyyyyyylllleeeexxxx(((())))  does  for  ordinary
  2289.           flex  scanners:  it  scans  the input stream, consuming
  2290.           tokens, until a rule's action returns a value.
  2291.  
  2292.      In addition, yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr  defines  the  following  protected
  2293.      virtual  functions which you can redefine in derived classes
  2294.      to tailor the scanner:
  2295.  
  2296.      vvvviiiirrrrttttuuuuaaaallll iiiinnnntttt LLLLeeeexxxxeeeerrrrIIIInnnnppppuuuutttt(((( cccchhhhaaaarrrr**** bbbbuuuuffff,,,, iiiinnnntttt mmmmaaaaxxxx____ssssiiiizzzzeeee ))))
  2297.           reads up to mmmmaaaaxxxx____ssssiiiizzzzeeee characters into  bbbbuuuuffff  and  returns
  2298.           the  number  of  characters  read.  To indicate end-of-
  2299.           input, return 0 characters.   Note  that  "interactive"
  2300.           scanners  (see  the   ----BBBB and ----IIII flags) define the macro
  2301.           YYYYYYYY____IIIINNNNTTTTEEEERRRRAAAACCCCTTTTIIIIVVVVEEEE.... If you redefine LLLLeeeexxxxeeeerrrrIIIInnnnppppuuuutttt(((())))  and  need
  2302.           to  take  different actions depending on whether or not
  2303.           the scanner might  be  scanning  an  interactive  input
  2304.  
  2305.  
  2306.  
  2307. Version 2.4        Last change: November 1993                  35
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2315.  
  2316.  
  2317.  
  2318.           source,  you can test for the presence of this name via
  2319.           ####iiiiffffddddeeeeffff....
  2320.  
  2321.      vvvviiiirrrrttttuuuuaaaallll vvvvooooiiiidddd LLLLeeeexxxxeeeerrrrOOOOuuuuttttppppuuuutttt(((( ccccoooonnnnsssstttt cccchhhhaaaarrrr**** bbbbuuuuffff,,,, iiiinnnntttt ssssiiiizzzzeeee ))))
  2322.           writes out ssssiiiizzzzeeee characters from the buffer bbbbuuuuffff,,,,  which,
  2323.           while NUL-terminated, may also contain "internal" NUL's
  2324.           if the scanner's rules can match  text  with  NUL's  in
  2325.           them.
  2326.  
  2327.      vvvviiiirrrrttttuuuuaaaallll vvvvooooiiiidddd LLLLeeeexxxxeeeerrrrEEEErrrrrrrroooorrrr(((( ccccoooonnnnsssstttt cccchhhhaaaarrrr**** mmmmssssgggg ))))
  2328.           reports a fatal error message.  The default version  of
  2329.           this function writes the message to the stream cccceeeerrrrrrrr and
  2330.           exits.
  2331.  
  2332.      Note that a yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr object contains its _e_n_t_i_r_e  scanning
  2333.      state.   Thus  you  can use such objects to create reentrant
  2334.      scanners.  You can instantiate  multiple  instances  of  the
  2335.      same  yyyyyyyyFFFFlllleeeexxxxLLLLeeeexxxxeeeerrrr  class,  and you can also combine multiple
  2336.      C++ scanner classes together in the same program using the ----
  2337.      PPPP option discussed above.
  2338.  
  2339.      Finally, note that the %%%%aaaarrrrrrrraaaayyyy feature is  not  available  to
  2340.      C++ scanner classes; you must use %%%%ppppooooiiiinnnntttteeeerrrr (the default).
  2341.  
  2342.      Here is an example of a simple C++ scanner:
  2343.  
  2344.              // An example of using the flex C++ scanner class.
  2345.  
  2346.          %{
  2347.          int mylineno = 0;
  2348.          %}
  2349.  
  2350.          string  \"[^\n"]+\"
  2351.  
  2352.          ws      [ \t]+
  2353.  
  2354.          alpha   [A-Za-z]
  2355.          dig     [0-9]
  2356.          name    ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])*
  2357.          num1    [-+]?{dig}+\.?([eE][-+]?{dig}+)?
  2358.          num2    [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
  2359.          number  {num1}|{num2}
  2360.  
  2361.          %%
  2362.  
  2363.          {ws}    /* skip blanks and tabs */
  2364.  
  2365.          "/*"    {
  2366.                  int c;
  2367.  
  2368.                  while((c = yyinput()) != 0)
  2369.                      {
  2370.  
  2371.  
  2372.  
  2373. Version 2.4        Last change: November 1993                  36
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2381.  
  2382.  
  2383.  
  2384.                      if(c == '\n')
  2385.                          ++mylineno;
  2386.  
  2387.                      else if(c == '*')
  2388.                          {
  2389.                          if((c = yyinput()) == '/')
  2390.                              break;
  2391.                          else
  2392.                              unput(c);
  2393.                          }
  2394.                      }
  2395.                  }
  2396.  
  2397.          {number}  cout << "number " << YYText() << '\n';
  2398.  
  2399.          \n        mylineno++;
  2400.  
  2401.          {name}    cout << "name " << YYText() << '\n';
  2402.  
  2403.          {string}  cout << "string " << YYText() << '\n';
  2404.  
  2405.          %%
  2406.  
  2407.          int main( int /* argc */, char** /* argv */ )
  2408.              {
  2409.              FlexLexer* lexer = new yyFlexLexer;
  2410.              while(lexer->yylex() != 0)
  2411.                  ;
  2412.              return 0;
  2413.              }
  2414.      IMPORTANT: the present form of the scanning class is _e_x_p_e_r_i_-
  2415.      _m_e_n_t_a_l and may change considerably between major releases.
  2416.  
  2417. IIIINNNNCCCCOOOOMMMMPPPPAAAATTTTIIIIBBBBIIIILLLLIIIITTTTIIIIEEEESSSS WWWWIIIITTTTHHHH LLLLEEEEXXXX AAAANNNNDDDD PPPPOOOOSSSSIIIIXXXX
  2418.      _f_l_e_x is a rewrite of the AT&T Unix _l_e_x tool (the two  imple-
  2419.      mentations  do not share any code, though), with some exten-
  2420.      sions and incompatibilities, both of which are of concern to
  2421.      those who wish to write scanners acceptable to either imple-
  2422.      mentation.  The POSIX _l_e_x specification is closer to  _f_l_e_x'_s
  2423.      behavior  than  that of the original _l_e_x implementation, but
  2424.      there also remain some incompatibilities  between  _f_l_e_x  and
  2425.      POSIX.   The  intent  is  that ultimately _f_l_e_x will be fully
  2426.      POSIX-conformant.  In this section we  discuss  all  of  the
  2427.      known areas of incompatibility.
  2428.  
  2429.      _f_l_e_x'_s ----llll option turns on  maximum  compatibility  with  the
  2430.      original  AT&T  _l_e_x  implementation,  at the cost of a major
  2431.      loss in the generated scanner's performance.  We note  below
  2432.      which incompatibilities can be overcome using the ----llll option.
  2433.  
  2434.      _f_l_e_x is fully compatible with _l_e_x with the following  excep-
  2435.      tions:
  2436.  
  2437.  
  2438.  
  2439. Version 2.4        Last change: November 1993                  37
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2447.  
  2448.  
  2449.  
  2450.      -    The undocumented _l_e_x scanner internal variable yyyyyyyylllliiiinnnneeeennnnoooo
  2451.           is not supported unless ----llll is used.
  2452.  
  2453.           yylineno is not part of the POSIX specification.
  2454.  
  2455.      -    The iiiinnnnppppuuuutttt(((()))) routine is not redefinable, though  it  may
  2456.           be  called  to  read  characters following whatever has
  2457.           been matched by a rule.  If iiiinnnnppppuuuutttt(((()))) encounters an  end-
  2458.           of-file  the  normal  yyyyyyyywwwwrrrraaaapppp(((())))  processing  is done.  A
  2459.           ``real'' end-of-file is returned by iiiinnnnppppuuuutttt(((()))) as _E_O_F.
  2460.  
  2461.           Input is instead controlled by  defining  the  YYYYYYYY____IIIINNNNPPPPUUUUTTTT
  2462.           macro.
  2463.  
  2464.           The _f_l_e_x restriction that iiiinnnnppppuuuutttt(((()))) cannot  be  redefined
  2465.           is  in  accordance  with the POSIX specification, which
  2466.           simply does not specify  any  way  of  controlling  the
  2467.           scanner's input other than by making an initial assign-
  2468.           ment to _y_y_i_n.
  2469.  
  2470.      -    _f_l_e_x scanners are not as reentrant as _l_e_x scanners.  In
  2471.           particular,  if  you have an interactive scanner and an
  2472.           interrupt handler which long-jumps out of the  scanner,
  2473.           and  the  scanner is subsequently called again, you may
  2474.           get the following message:
  2475.  
  2476.               fatal flex scanner internal error--end of buffer missed
  2477.  
  2478.           To reenter the scanner, first use
  2479.  
  2480.               yyrestart( yyin );
  2481.  
  2482.           Note that this call will throw away any buffered input;
  2483.           usually  this  isn't  a  problem  with  an  interactive
  2484.           scanner.
  2485.  
  2486.           Also note that flex C++ scanner classes _a_r_e  reentrant,
  2487.           so  if  using  C++ is an option for you, you should use
  2488.           them instead.  See "Generating C++ Scanners" above  for
  2489.           details.
  2490.  
  2491.      -    oooouuuuttttppppuuuutttt(((()))) is not supported.  Output from the EEEECCCCHHHHOOOO  macro
  2492.           is done to the file-pointer _y_y_o_u_t (default _s_t_d_o_u_t).
  2493.  
  2494.           oooouuuuttttppppuuuutttt(((()))) is not part of the POSIX specification.
  2495.  
  2496.      -    _l_e_x does not support exclusive start  conditions  (%x),
  2497.           though they are in the POSIX specification.
  2498.  
  2499.      -    When definitions are expanded, _f_l_e_x  encloses  them  in
  2500.           parentheses.  With lex, the following:
  2501.  
  2502.  
  2503.  
  2504.  
  2505. Version 2.4        Last change: November 1993                  38
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2513.  
  2514.  
  2515.  
  2516.               NAME    [A-Z][A-Z0-9]*
  2517.               %%
  2518.               foo{NAME}?      printf( "Found it\n" );
  2519.               %%
  2520.  
  2521.           will not match the string "foo" because when the  macro
  2522.           is  expanded  the rule is equivalent to "foo[A-Z][A-Z0-
  2523.           9]*?"  and the precedence is such that the '?' is asso-
  2524.           ciated  with  "[A-Z0-9]*".  With _f_l_e_x, the rule will be
  2525.           expanded to "foo([A-Z][A-Z0-9]*)?" and  so  the  string
  2526.           "foo" will match.
  2527.  
  2528.           Note that if the definition begins with ^^^^ or ends  with
  2529.           $$$$  then  it  is _n_o_t expanded with parentheses, to allow
  2530.           these operators to appear in definitions without losing
  2531.           their  special  meanings.   But the <<<<ssss>>>>,,,, ////,,,, and <<<<<<<<EEEEOOOOFFFF>>>>>>>>
  2532.           operators cannot be used in a _f_l_e_x definition.
  2533.  
  2534.           Using ----llll results in the _l_e_x behavior of no  parentheses
  2535.           around the definition.
  2536.  
  2537.           The POSIX  specification  is  that  the  definition  be
  2538.           enclosed in parentheses.
  2539.  
  2540.      -    The _l_e_x %%%%rrrr (generate a Ratfor scanner)  option  is  not
  2541.           supported.  It is not part of the POSIX specification.
  2542.  
  2543.      -    After a call to uuuunnnnppppuuuutttt(((()))),,,, _y_y_t_e_x_t and  _y_y_l_e_n_g  are  unde-
  2544.           fined  until  the  next  token  is  matched, unless the
  2545.           scanner was built using %%%%aaaarrrrrrrraaaayyyy.... This is  not  the  case
  2546.           with  _l_e_x  or  the  POSIX specification.  The ----llll option
  2547.           does away with this incompatibility.
  2548.  
  2549.      -    The precedence of the {{{{}}}} (numeric  range)  operator  is
  2550.           different.   _l_e_x  interprets  "abc{1,3}" as "match one,
  2551.           two, or  three  occurrences  of  'abc'",  whereas  _f_l_e_x
  2552.           interprets  it  as "match 'ab' followed by one, two, or
  2553.           three occurrences of 'c'".  The latter is in  agreement
  2554.           with the POSIX specification.
  2555.  
  2556.      -    The precedence of the ^^^^  operator  is  different.   _l_e_x
  2557.           interprets  "^foo|bar"  as  "match  either 'foo' at the
  2558.           beginning of a line, or 'bar' anywhere",  whereas  _f_l_e_x
  2559.           interprets  it  as "match either 'foo' or 'bar' if they
  2560.           come at the beginning of a line".   The  latter  is  in
  2561.           agreement with the POSIX specification.
  2562.  
  2563.      -    _y_y_i_n is _i_n_i_t_i_a_l_i_z_e_d by _l_e_x to be _s_t_d_i_n;  _f_l_e_x,  on  the
  2564.           other  hand,  initializes _y_y_i_n to NULL and then _a_s_s_i_g_n_s
  2565.           it to _s_t_d_i_n the first time the scanner is called,  pro-
  2566.           viding _y_y_i_n has not already been assigned to a non-NULL
  2567.           value.  The difference is subtle, but the net effect is
  2568.  
  2569.  
  2570.  
  2571. Version 2.4        Last change: November 1993                  39
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2579.  
  2580.  
  2581.  
  2582.           that  with  _f_l_e_x  scanners,  _y_y_i_n does not have a valid
  2583.           value until the scanner has been called.
  2584.  
  2585.           The ----llll option does away with this incompatibility.
  2586.  
  2587.      -    The special table-size declarations  such  as  %%%%aaaa  sup-
  2588.           ported  by  _l_e_x are not required by _f_l_e_x scanners; _f_l_e_x
  2589.           ignores them.
  2590.  
  2591.      -    The name FLEX_SCANNER is #define'd so scanners  may  be
  2592.           written for use with either _f_l_e_x or _l_e_x.
  2593.  
  2594.      The following _f_l_e_x features are not included in _l_e_x  or  the
  2595.      POSIX specification:
  2596.  
  2597.          yyterminate()
  2598.          <<EOF>>
  2599.          <*>
  2600.          YY_DECL
  2601.          YY_START
  2602.          YY_USER_ACTION
  2603.          #line directives
  2604.          %{}'s around actions
  2605.          multiple actions on a line
  2606.  
  2607.      plus almost all of the flex flags.  The last feature in  the
  2608.      list  refers to the fact that with _f_l_e_x you can put multiple
  2609.      actions on the same line, separated with semi-colons,  while
  2610.      with _l_e_x, the following
  2611.  
  2612.          foo    handle_foo(); ++num_foos_seen;
  2613.  
  2614.      is (rather surprisingly) truncated to
  2615.  
  2616.          foo    handle_foo();
  2617.  
  2618.      _f_l_e_x does not truncate the action.   Actions  that  are  not
  2619.      enclosed  in  braces are simply terminated at the end of the
  2620.      line.
  2621.  
  2622. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  2623.      _w_a_r_n_i_n_g, _r_u_l_e _c_a_n_n_o_t _b_e _m_a_t_c_h_e_d  indicates  that  the  given
  2624.      rule  cannot  be matched because it follows other rules that
  2625.      will always match the same text as it.  For example, in  the
  2626.      following  "foo" cannot be matched because it comes after an
  2627.      identifier "catch-all" rule:
  2628.  
  2629.          [a-z]+    got_identifier();
  2630.          foo       got_foo();
  2631.  
  2632.      Using RRRREEEEJJJJEEEECCCCTTTT in a scanner suppresses this warning.
  2633.  
  2634.  
  2635.  
  2636.  
  2637. Version 2.4        Last change: November 1993                  40
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2645.  
  2646.  
  2647.  
  2648.      _w_a_r_n_i_n_g, ----ssss _o_p_t_i_o_n _g_i_v_e_n _b_u_t _d_e_f_a_u_l_t  _r_u_l_e  _c_a_n  _b_e  _m_a_t_c_h_e_d
  2649.      means  that  it  is  possible  (perhaps only in a particular
  2650.      start condition) that the default  rule  (match  any  single
  2651.      character)  is  the  only  one  that will match a particular
  2652.      input.  Since ----ssss was given, presumably this is not intended.
  2653.  
  2654.      _r_e_j_e_c_t__u_s_e_d__b_u_t__n_o_t__d_e_t_e_c_t_e_d          _u_n_d_e_f_i_n_e_d           or
  2655.      _y_y_m_o_r_e__u_s_e_d__b_u_t__n_o_t__d_e_t_e_c_t_e_d  _u_n_d_e_f_i_n_e_d  -  These errors can
  2656.      occur at compile time.  They indicate that the scanner  uses
  2657.      RRRREEEEJJJJEEEECCCCTTTT  or yyyyyyyymmmmoooorrrreeee(((()))) but that _f_l_e_x failed to notice the fact,
  2658.      meaning that _f_l_e_x scanned the first two sections looking for
  2659.      occurrences  of  these  actions  and failed to find any, but
  2660.      somehow you snuck some in (via a #include  file,  for  exam-
  2661.      ple).  Make an explicit reference to the action in your _f_l_e_x
  2662.      input  file.   (Note  that  previously  _f_l_e_x   supported   a
  2663.      %%%%uuuusssseeeedddd////%%%%uuuunnnnuuuusssseeeedddd  mechanism for dealing with this problem; this
  2664.      feature is still supported but now deprecated, and  will  go
  2665.      away  soon unless the author hears from people who can argue
  2666.      compellingly that they need it.)
  2667.  
  2668.      _f_l_e_x _s_c_a_n_n_e_r _j_a_m_m_e_d - a scanner compiled with ----ssss has encoun-
  2669.      tered  an  input  string  which wasn't matched by any of its
  2670.      rules.  This error can also occur due to internal problems.
  2671.  
  2672.      _t_o_k_e_n _t_o_o _l_a_r_g_e, _e_x_c_e_e_d_s _Y_Y_L_M_A_X - your scanner  uses  %%%%aaaarrrrrrrraaaayyyy
  2673.      and one of its rules matched a string longer than the YYYYYYYYLLLLMMMMAAAAXXXX
  2674.      constant (8K bytes by default).  You can increase the  value
  2675.      by  #define'ing  YYYYYYYYLLLLMMMMAAAAXXXX  in  the definitions section of your
  2676.      _f_l_e_x input.
  2677.  
  2678.      _s_c_a_n_n_e_r _r_e_q_u_i_r_e_s -_8 _f_l_a_g _t_o _u_s_e _t_h_e  _c_h_a_r_a_c_t_e_r  '_x'  -  Your
  2679.      scanner specification includes recognizing the 8-bit charac-
  2680.      ter '_x' and you did not  specify  the  - 8  flag,  and  your
  2681.      scanner  defaulted  to 7-bit because you used the ----CCCCffff or ----CCCCFFFF
  2682.      table compression options.  See the discussion of  the   ---- 7777
  2683.      flag for details.
  2684.  
  2685.      _f_l_e_x _s_c_a_n_n_e_r _p_u_s_h-_b_a_c_k _o_v_e_r_f_l_o_w - you used uuuunnnnppppuuuutttt(((())))  to  push
  2686.      back  so  much text that the scanner's buffer could not hold
  2687.      both the pushed-back text and the current token  in  yyyyyyyytttteeeexxxxtttt....
  2688.      Ideally  the scanner should dynamically resize the buffer in
  2689.      this case, but at present it does not.
  2690.  
  2691.      _i_n_p_u_t _b_u_f_f_e_r _o_v_e_r_f_l_o_w, _c_a_n'_t _e_n_l_a_r_g_e _b_u_f_f_e_r _b_e_c_a_u_s_e  _s_c_a_n_n_e_r
  2692.      _u_s_e_s  _R_E_J_E_C_T  -  the  scanner  was  working  on  matching an
  2693.      extremely large token and needed to expand the input buffer.
  2694.      This doesn't work with scanners that use RRRREEEEJJJJEEEECCCCTTTT....
  2695.  
  2696.      _f_a_t_a_l _f_l_e_x _s_c_a_n_n_e_r _i_n_t_e_r_n_a_l _e_r_r_o_r--_e_n_d _o_f  _b_u_f_f_e_r  _m_i_s_s_e_d  -
  2697.      This  can  occur  in  an  scanner which is reentered after a
  2698.      long-jump has jumped out (or over) the scanner's  activation
  2699.      frame.  Before reentering the scanner, use:
  2700.  
  2701.  
  2702.  
  2703. Version 2.4        Last change: November 1993                  41
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2711.  
  2712.  
  2713.  
  2714.          yyrestart( yyin );
  2715.  
  2716.      or, as noted above, switch to using the C++ scanner class.
  2717.  
  2718.      _t_o_o _m_a_n_y _s_t_a_r_t _c_o_n_d_i_t_i_o_n_s _i_n <> you listed more start condi-
  2719.      tions  in a <> construct than exist (so you must have listed
  2720.      at least one of them twice).
  2721.  
  2722. FFFFIIIILLLLEEEESSSS
  2723.      See flex(1).
  2724.  
  2725. DDDDEEEEFFFFIIIICCCCIIIIEEEENNNNCCCCIIIIEEEESSSS //// BBBBUUUUGGGGSSSS
  2726.      Again, see flex(1).
  2727.  
  2728. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  2729.      flex(1), lex(1), yacc(1), sed(1), awk(1).
  2730.  
  2731.      M. E. Lesk and E. Schmidt, _L_E_X - _L_e_x_i_c_a_l _A_n_a_l_y_z_e_r _G_e_n_e_r_a_t_o_r
  2732.  
  2733. AAAAUUUUTTTTHHHHOOOORRRR
  2734.      Vern Paxson, with the help of many ideas and  much  inspira-
  2735.      tion  from Van Jacobson.  Original version by Jef Poskanzer.
  2736.      The fast table representation is a partial implementation of
  2737.      a  design done by Van Jacobson.  The implementation was done
  2738.      by Kevin Gong and Vern Paxson.
  2739.  
  2740.      Thanks to the many _f_l_e_x beta-testers, feedbackers, and  con-
  2741.      tributors,  especially Francois Pinard, Casey Leedom, Nelson
  2742.      H.F. Beebe, benson@odi.com, Peter A.  Bigot,  Keith  Bostic,
  2743.      Frederic  Brehm, Nick Christopher, Jason Coughlin, Bill Cox,
  2744.      Dave Curtis, Scott David Daniels, Chris G.  Demetriou,  Mike
  2745.      Donahue,  Chuck Doucette, Tom Epperly, Leo Eskin, Chris Fay-
  2746.      lor, Jon Forrest,  Kaveh  R.  Ghazi,  Eric  Goldman,  Ulrich
  2747.      Grepel,  Jan  Hajic,  Jarkko  Hietaniemi,  Eric Hughes, John
  2748.      Interrante, Ceriel Jacobs, Jeffrey R. Jones, Henry  Juengst,
  2749.      Amir  Katz,  ken@ken.hilco.com,  Kevin  B. Kenny, Marq Kole,
  2750.      Ronald Lamprecht, Greg Lee, Craig Leres, John Levine,  Steve
  2751.      Liddle,  Mohamed  el Lozy, Brian Madsen, Chris Metcalf, Luke
  2752.      Mewburn, Jim Meyering, G.T. Nicol, Landon Noll, Marc Nozell,
  2753.      Richard Ohnemus, Sven Panne, Roland Pesch, Walter Pelissero,
  2754.      Gaumond Pierre, Esmond  Pitt,  Jef  Poskanzer,  Joe  Rahmeh,
  2755.      Frederic  Raimbault,  Rick  Richardson,  Kevin  Rodgers, Jim
  2756.      Roskind, Doug Schmidt, Philippe Schnoebelen, Andreas Schwab,
  2757.      Alex  Siegel,  Mike  Stump, Paul Stuart, Dave Tallman, Chris
  2758.      Thewalt, Paul Tuinenga, Gary  Weik,  Frank  Whaley,  Gerhard
  2759.      Wilhelms,  Kent Williams, Ken Yap, Nathan Zelle, David Zuhn,
  2760.      and  those  whose  names  have  slipped  my  marginal  mail-
  2761.      archiving skills but whose contributions are appreciated all
  2762.      the same.
  2763.  
  2764.      Thanks to Keith Bostic, Jon  Forrest,  Noah  Friedman,  John
  2765.      Gilmore, Craig Leres, John Levine, Bob Mulcahy, G.T.  Nicol,
  2766.  
  2767.  
  2768.  
  2769. Version 2.4        Last change: November 1993                  42
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. FLEXDOC(1)                User Commands                FLEXDOC(1)
  2777.  
  2778.  
  2779.  
  2780.      Francois Pinard, Rich Salz, and Richard  Stallman  for  help
  2781.      with various distribution headaches.
  2782.  
  2783.      Thanks to Esmond Pitt and Earle Horton for  8-bit  character
  2784.      support; to Benson Margulies and Fred Burke for C++ support;
  2785.      to Kent Williams and Tom Epperly for C++ class  support;  to
  2786.      Ove  Ewerlid  for  support  of NUL's; and to Eric Hughes for
  2787.      support of multiple buffers.
  2788.  
  2789.      This work was primarily done when I was with the  Real  Time
  2790.      Systems  Group at the Lawrence Berkeley Laboratory in Berke-
  2791.      ley, CA.  Many  thanks  to  all  there  for  the  support  I
  2792.      received.
  2793.  
  2794.      Send comments to:
  2795.  
  2796.           Vern Paxson
  2797.           Systems Engineering
  2798.           Bldg. 46A, Room 1123
  2799.           Lawrence Berkeley Laboratory
  2800.           University of California
  2801.           Berkeley, CA 94720
  2802.  
  2803.           vern@ee.lbl.gov
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835. Version 2.4        Last change: November 1993                  43
  2836.  
  2837.  
  2838.  
  2839.